本文整理汇总了Java中org.apache.log4j.Priority类的典型用法代码示例。如果您正苦于以下问题:Java Priority类的具体用法?Java Priority怎么用?Java Priority使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Priority类属于org.apache.log4j包,在下文中一共展示了Priority类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapLevel
import org.apache.log4j.Priority; //导入依赖的package包/类
private int mapLevel(Level level) {
switch (level.toInt()) {
case Priority.DEBUG_INT:
case Priority.INFO_INT:
return IStatus.INFO;
case Priority.WARN_INT:
return IStatus.WARNING;
case Priority.ERROR_INT:
case Priority.FATAL_INT:
return IStatus.ERROR;
default:
return IStatus.INFO;
}
}
示例2: logStackTrace
import org.apache.log4j.Priority; //导入依赖的package包/类
public void logStackTrace(int traceLevel) {
if (needsLogging) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
StackTraceElement[] ste = new Exception().getStackTrace();
// Skip the log writer frame and log all the other stack frames.
for (int i = 1; i < ste.length; i++) {
String callFrame = "[" + ste[i].getFileName() + ":"
+ ste[i].getLineNumber() + "]";
pw.print(callFrame);
}
pw.close();
String stackTrace = sw.getBuffer().toString();
Level level = this.getLevel(traceLevel);
Priority priority = this.getLogPriority();
if ( level.isGreaterOrEqual(priority)) {
logger.log(level,stackTrace);
}
}
}
示例3: testAutoPopulate
import org.apache.log4j.Priority; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testAutoPopulate ()
{
final TestClock tc = new TestClock ( 1234567890123L );
final EcompLayout layout = new EcompLayout ();
MDC.put ( EcompFields.kBeginTimestampMs, Long.toString ( SaClock.now () ) );
tc.forward ( 60*1000L );
layout.format ( new LoggingEvent ( "foo.bar", Category.getRoot (), Priority.INFO, "foobar", null ) );
assertEquals ( "2009-02-13T23:31:30.123+00:00", MDC.get ( EcompFields.kBeginTimestamp ) );
assertEquals ( "2009-02-13T23:32:30.123+00:00", MDC.get ( EcompFields.kEndTimestamp ) );
assertEquals ( "60000", MDC.get ( EcompFields.kElapsedTimeMs ) );
}
示例4: LoggingOutputStream
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Creates the LoggingOutputStream to flush to the given Category.
*
* @param cat the Category to write to
*
* @param priority the Priority to use when writing to the Category
*
* @exception IllegalArgumentException
* if cat == null or priority == null
*/
public LoggingOutputStream(Category cat, Priority priority)
throws IllegalArgumentException {
if (cat == null) {
throw new IllegalArgumentException("cat == null");
}
if (priority == null) {
throw new IllegalArgumentException("priority == null");
}
this.priority = priority;
category = cat;
bufLength = DEFAULT_BUFFER_LENGTH;
buf = new byte[DEFAULT_BUFFER_LENGTH];
count = 0;
}
示例5: setUp
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* @throws Exception
*/
@Before public void setUp() throws Exception {
new MockUp<Category>() {
@SuppressWarnings("unused")
@Mock public boolean isDebugEnabled() {
return true;
}
@SuppressWarnings("unused")
@Mock public boolean isEnabledFor(Priority level) {
return true;
}
@SuppressWarnings("unused")
@Mock public boolean isInfoEnabled() {
return true;
}
};
logService = new StandardLogService(this.getClass().getName());
}
示例6: addIdeFatalMessage
import org.apache.log4j.Priority; //导入依赖的package包/类
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
Object data = aEvent.getData();
final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
if (myFatalsGrouper.addToGroup(message)) {
return message;
}
} else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
myFatalsGrouper.addToGroup(tooMany);
return tooMany;
}
return null;
}
示例7: EventDetails
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Creates a new <code>EventDetails</code> instance.
* @param aTimeStamp a <code>long</code> value
* @param aPriority a <code>Priority</code> value
* @param aCategoryName a <code>String</code> value
* @param aNDC a <code>String</code> value
* @param aThreadName a <code>String</code> value
* @param aMessage a <code>String</code> value
* @param aThrowableStrRep a <code>String[]</code> value
* @param aLocationDetails a <code>String</code> value
*/
EventDetails(long aTimeStamp,
Priority aPriority,
String aCategoryName,
String aNDC,
String aThreadName,
String aMessage,
String[] aThrowableStrRep,
String aLocationDetails)
{
mTimeStamp = aTimeStamp;
mPriority = aPriority;
mCategoryName = aCategoryName;
mNDC = aNDC;
mThreadName = aThreadName;
mMessage = aMessage;
mThrowableStrRep = aThrowableStrRep;
mLocationDetails = aLocationDetails;
}
示例8: testLocationInfoNoFQCN
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Tests LoggingEvent.getLocationInfo() when no FQCN is specified.
* See bug 41186.
*/
public void testLocationInfoNoFQCN() {
Category root = Logger.getRootLogger();
Priority level = Level.INFO;
LoggingEvent event =
new LoggingEvent(
null, root, 0L, level, "Hello, world.", null);
LocationInfo info = event.getLocationInformation();
//
// log4j 1.2 returns an object, its layout doesn't check for nulls.
// log4j 1.3 returns a null.
//
assertNotNull(info);
if (info != null) {
assertEquals("?", info.getLineNumber());
assertEquals("?", info.getClassName());
assertEquals("?", info.getFileName());
assertEquals("?", info.getMethodName());
}
}
示例9: run
import org.apache.log4j.Priority; //导入依赖的package包/类
public
void run() {
while(true) {
synchronized(this) {
try {
this.wait();
} catch(Exception e) {
}
}
for(int i = 0; i < burst; i++) {
LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG,
"Message "+counter, null);
event.getThreadName();
if(counter % 50 == 0) {
//event.throwable = new Exception("hello "+counter);
}
counter++;
view.add(event);
}
}
}
示例10: getIconName
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Extract a reference to the static icon name
* @param levelInt the int value of the level
* @return an icon name
*/
private String getIconName() {
switch (level) {
case Priority.DEBUG_INT: {
return ICONS[0];
}
case Priority.INFO_INT: {
return ICONS[1];
}
case Priority.WARN_INT: {
return ICONS[2];
}
case Priority.ERROR_INT: {
return ICONS[3];
}
case Priority.FATAL_INT: {
return ICONS[4];
}
}
return null;
}
示例11: getLevelString
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Extract a reference to the static level strings
* @param levelInt the int value of the level
* @return a level string
*/
public String getLevelString() {
switch (level) {
case Priority.DEBUG_INT: {
return LEVELS[0];
}
case Priority.INFO_INT: {
return LEVELS[1];
}
case Priority.WARN_INT: {
return LEVELS[2];
}
case Priority.ERROR_INT: {
return LEVELS[3];
}
case Priority.FATAL_INT: {
return LEVELS[4];
}
}
return null;
}
示例12: getLevelFlag
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Fecth a flag for the current level to enable quick determination in a set of level flags
* @return the level flag for this log events level
*/
public int getLevelFlag() {
switch (level) {
case Priority.DEBUG_INT: {
return LEVEL_DEBUG_FLAG;
}
case Priority.INFO_INT: {
return LEVEL_INFO_FLAG;
}
case Priority.WARN_INT: {
return LEVEL_WARN_FLAG;
}
case Priority.ERROR_INT: {
return LEVEL_ERROR_FLAG;
}
case Priority.FATAL_INT: {
return LEVEL_FATAL_FLAG;
}
default: {
return 0;
}
}
}
示例13: internalInit
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* initializes the log system using the logfile argument
*/
private void internalInit( String logfile )
throws Exception
{
/*
* do it by our classname to avoid conflicting with anything else
* that might be used...
*/
logger = Category.getInstance(this.getClass().getName());
logger.setAdditivity(false);
/*
* Priority is set for DEBUG becouse this implementation checks
* log level.
*/
logger.setPriority(Priority.DEBUG);
RollingFileAppender appender = new RollingFileAppender( new PatternLayout( "%d - %m%n"), logfile, true);
appender.setMaxBackupIndex( 1 );
appender.setMaximumFileSize( 100000 );
logger.addAppender(appender);
}
示例14: threadLocalAwareLog
import org.apache.log4j.Priority; //导入依赖的package包/类
/**
* Logger worker method - does the actual checks whether the given message should be logged at the given priority - taking into account this logger's loglevel plus
* the threadLocalLogLevel.
*
* @param priority
* the priority at which the given message should be logged
* @param message
* the message which should be logged (or not, depending on levels)
*/
private final void threadLocalAwareLog(String fQCN, Priority priority, Object message, Throwable t) {
if (isForcedToLog(priority)) {
final Appender forcedAppender = getForcedAppender();
// force the logging and modify the log message (the latter might return the original message)
if (forcedAppender != null) {
// only call the forced appender
forcedAppender.doAppend(new LoggingEvent(fQCN, this, priority, modifyLogMessage(message), t));
} else {
// go via the normal appenders
forcedLog(fQCN, priority, modifyLogMessage(message), t);
}
} else {
// else not forced to log - use default behaviour
super.log(fQCN, priority, message, t);
}
}
示例15: l7dlog
import org.apache.log4j.Priority; //导入依赖的package包/类
@Override
public void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
if (isForcedToLog(priority)) {
// from super.l7dlog:
String pattern = getResourceBundleString(key);
String msg;
if (pattern == null)
msg = key;
else
msg = java.text.MessageFormat.format(pattern, params);
final Appender forcedAppender = getForcedAppender();
// force the logging and modify the log message (the latter might return the original message)
if (forcedAppender != null) {
// only call the forced appender
forcedAppender.doAppend(new LoggingEvent(FQCN, this, priority, modifyLogMessage(msg), t));
} else {
// go via the normal appenders
forcedLog(FQCN, priority, modifyLogMessage(msg), t);
}
} else {
super.l7dlog(priority, key, params, t);
}
}