本文整理匯總了Java中org.apache.log4j.Level.ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java Level.ERROR屬性的具體用法?Java Level.ERROR怎麽用?Java Level.ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.log4j.Level
的用法示例。
在下文中一共展示了Level.ERROR屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: format
public String format(LoggingEvent event){
if( event.getLevel() == Level.FATAL){
return fatalErrorColor+super.format(event)+END_COLOR;
}else if( event.getLevel() == Level.ERROR){
return errorColor+super.format(event)+END_COLOR;
}if( event.getLevel() == Level.WARN){
return super.format(event);
// return warnColor+super.format(event)+END_COLOR;
}if( event.getLevel() == Level.INFO){
return super.format(event);
// return infoColor+super.format(event)+END_COLOR;
}if( event.getLevel() == Level.DEBUG){
return super.format(event);
// return debugColor+super.format(event)+END_COLOR;
}else{
throw new RuntimeException("Unsupported Level "+event.toString());
}
}
示例2: intToLevel
public static Level intToLevel(int intLevel) {
switch(intLevel) {
case TRACE_INFO: return Level.INFO;
case TRACE_DEBUG: return Level.DEBUG;
case TRACE_ERROR: return Level.ERROR;
case TRACE_WARN: return Level.WARN;
case TRACE_TRACE: return Level.TRACE;
case TRACE_FATAL: return Level.FATAL;
}
return Level.OFF;
}
示例3: getLevel
public Level getLevel(int traceLevel) {
if ( traceLevel == TRACE_INFO ) {
return Level.INFO;
} else if ( traceLevel == TRACE_ERROR ) {
return Level.ERROR;
} else if ( traceLevel == TRACE_DEBUG) {
return Level.DEBUG;
} else if (traceLevel == TRACE_TRACE) {
return Level.ALL;
} else {
return Level.OFF;
}
}
示例4: setLogLevel
private void setLogLevel(String level) {
Level newLevel = Level.ERROR;
level = level.substring(level.lastIndexOf(' ') + 1);
switch (level) {
case "Debug":
newLevel = Level.DEBUG;
break;
case "Info":
newLevel = Level.INFO;
break;
case "Warn":
newLevel = Level.WARN;
break;
case "Error":
newLevel = Level.ERROR;
break;
}
Logger.getRootLogger().setLevel(newLevel);
logger.setLevel(newLevel);
ConsoleAppender ca = (ConsoleAppender)Logger.getRootLogger().getAppender("stdout");
if (ca != null) {
ca.setThreshold(newLevel);
}
FileAppender fa = (FileAppender)Logger.getRootLogger().getAppender("FILE");
if (fa != null) {
fa.setThreshold(newLevel);
}
}
示例5: main
public static void main(String[] args) throws Exception {
System.out.println("Benchmark: RPC session establishment.");
if(args.length < 1)
printUsage();
Configuration conf = new Configuration();
int count = Integer.parseInt(args[0]);
if(args.length > 1)
conf.set(KEYTAB_FILE_KEY, args[1]);
if(args.length > 2)
conf.set(USER_NAME_KEY, args[2]);
boolean useDelegationToken = false;
if(args.length > 3)
useDelegationToken = args[3].equalsIgnoreCase("useToken");
Level l = Level.ERROR;
if(args.length > 4)
l = Level.toLevel(args[4]);
MiniRPCBenchmark mb = new MiniRPCBenchmark(l);
long elapsedTime = 0;
if(useDelegationToken) {
System.out.println(
"Running MiniRPCBenchmark with delegation token authentication.");
elapsedTime = mb.runMiniBenchmarkWithDelegationToken(
conf, count, KEYTAB_FILE_KEY, USER_NAME_KEY);
} else {
String auth = SecurityUtil.getAuthenticationMethod(conf).toString();
System.out.println(
"Running MiniRPCBenchmark with " + auth + " authentication.");
elapsedTime = mb.runMiniBenchmark(
conf, count, KEYTAB_FILE_KEY, USER_NAME_KEY);
}
System.out.println(org.apache.hadoop.util.VersionInfo.getVersion());
System.out.println("Number of connects: " + count);
System.out.println("Average connect time: " + ((double)elapsedTime/count));
}
示例6: append
@Override
protected void append(final LoggingEvent loggingEvent)
{
if(loggingEvent.getLevel() == Level.ERROR)
{
log.add(loggingEvent);
}
}
示例7: determineLogLevel
/**
* Determines the log level represented by the configuration setting. If the
* stored value does not match any of the supported log levels, the default
* log level INFO will be used.
*
* @param logLevel
* The log level information read from the configuration
* settings.
* @return The log4j compliant log level to be used.
*/
private static Level determineLogLevel(String logLevel) {
Level level = Level.INFO;
if (DEBUG_LOG_LEVEL.equals(logLevel)) {
level = Level.DEBUG;
} else if (WARN_LOG_LEVEL.equals(logLevel)) {
level = Level.WARN;
} else if (ERROR_LOG_LEVEL.equals(logLevel)) {
level = Level.ERROR;
} else if (INFO_LOG_LEVEL.equals(logLevel)) {
level = Level.INFO;
}
return level;
}
示例8: writeToLog
@Override
public synchronized void writeToLog(int messageLogLevel, String message) {
Priority priority = Level.TRACE;
if (messageLogLevel == Log.LOGLEVEL_FATAL_ERROR) priority = Level.FATAL;
else if (messageLogLevel == Log.LOGLEVEL_EXCEPTION) priority = Level.ERROR;
else if (messageLogLevel == Log.LOGLEVEL_WARNING) priority = Level.WARN;
else if (messageLogLevel == Log.LOGLEVEL_MESSAGE) priority = Level.INFO;
else if (messageLogLevel == Log.LOGLEVEL_DEBUG) priority = Level.DEBUG;
else if (messageLogLevel == Log.LOGLEVEL_DEBUG2) priority = Level.TRACE;
else if (messageLogLevel == Log.LOGLEVEL_DEBUG3) priority = Level.TRACE;
logger.log(priority, message);
}
示例9: OperationStatsBase
OperationStatsBase() {
baseDir = BASE_DIR_NAME + "/" + getOpName();
replication = (short) config.getInt(DFSConfigKeys.DFS_REPLICATION_KEY, 3);
numOpsRequired = 10;
numThreads = 3;
logLevel = Level.ERROR;
ugcRefreshCount = Integer.MAX_VALUE;
}
示例10: setLogLevel
/**
* Set logging level to given value. If not explicitly
* specified, default level is used from *logger* properties file.
* (As of the time writing - simplelogger.properties is used as default.)
* <p/>
* NOTE: SLF4J is not capable of changing log levels programatically!
* We have to change the System/File property of given underlying logger.
*
* @param logLevel logging level to be logger set to
*/
public static void setLogLevel(String logLevel) {
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("com.redhat.mqe.jms");
Level level;
switch (logLevel.toLowerCase()) {
case "all":
level = Level.ALL;
break;
case "trace":
level = Level.TRACE;
break;
case "debug":
level = Level.DEBUG;
break;
case "info":
level = Level.INFO;
break;
case "warn":
level = Level.WARN;
break;
case "error":
level = Level.ERROR;
break;
case "fatal":
level = Level.FATAL;
break;
case "off":
level = Level.OFF;
break;
default:
level = Level.INFO;
}
LogManager.getRootLogger().setLevel(level);
logger.setLevel(level);
}