當前位置: 首頁>>代碼示例>>Java>>正文


Java LoggingEvent.getLevel方法代碼示例

本文整理匯總了Java中org.apache.log4j.spi.LoggingEvent.getLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java LoggingEvent.getLevel方法的具體用法?Java LoggingEvent.getLevel怎麽用?Java LoggingEvent.getLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.spi.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.getLevel方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
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());
    }
    }
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:19,代碼來源:ColoredPatternLayout.java

示例2: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public void append(LoggingEvent event) {
  Level level = event.getLevel();
  // depends on the api, == might not work
  // see HADOOP-7055 for details
  if (level.equals(Level.INFO)) {
    counts.incr(INFO);
  }
  else if (level.equals(Level.WARN)) {
    counts.incr(WARN);
  }
  else if (level.equals(Level.ERROR)) {
    counts.incr(ERROR);
  }
  else if (level.equals(Level.FATAL)) {
    counts.incr(FATAL);
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:19,代碼來源:EventCounter.java

示例3: FastLoggingEvent

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
public FastLoggingEvent(LoggingEvent event, int stackOffset) {
    super(event.getFQNOfLoggerClass(),
          event.getLogger(),
          event.getLevel(),
          event.getMessage(),
          (event.getThrowableInformation() != null ? event.getThrowableInformation().getThrowable() : null));
    this.event = event;
    this.stackOffset = stackOffset;
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:10,代碼來源:FastLoggingEvent.java

示例4: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
protected void append(final LoggingEvent loggingEvent)
{
    if(loggingEvent.getLevel() == Level.ERROR)
    {
        log.add(loggingEvent);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:9,代碼來源:ThumbnailServiceImplTest.java

示例5: defaultLogFormat

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
static private Object defaultLogFormat(LoggingEvent loggingEvent) {

        LoggingEventX eventX = new LoggingEventX(loggingEvent.getFQNOfLoggerClass(), loggingEvent.getLogger()
                , loggingEvent.getTimeStamp(), loggingEvent.getLevel(), loggingEvent.getMessage(),
                loggingEvent.getThreadName(), loggingEvent.getThrowableInformation(), loggingEvent.getNDC(),
                loggingEvent.getLocationInformation(), loggingEvent.getProperties());

        eventX.setLogTime(new Date(loggingEvent.getTimeStamp()));
        eventX.setLogLevel(eventX.getLevel().toString());
        return eventX;
    }
 
開發者ID:Crab2died,項目名稱:log4j-redis-appender,代碼行數:12,代碼來源:RedisAppender.java

示例6: assertLogged

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
public static void assertLogged(Level level, String message) {
    for (LoggingEvent event : getTestAppender().getEvents()) {
        if (event.getLevel() == level && event.getMessage().toString().contains(message)) {
            return;
        }
    }

    Assert.fail("For level " + level + ", failed to find logged message " + message);
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:10,代碼來源:TestUtil.java

示例7: serializeLoggingEvent

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
private String serializeLoggingEvent(LoggingEvent loggingEvent, Log4jALAAppender appender)
		throws JsonProcessingException {
	// http://stackoverflow.com/questions/11294307/convert-java-date-to-utc-string
	String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS zzz";
	SimpleDateFormat sdf = new SimpleDateFormat(ISO_FORMAT);
	sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

	HashMap<String, Object> payload = new HashMap<String, Object>();
	
	Object logMessage = loggingEvent.getMessage();

	if (!StringUtils.isEmpty(appender.getEnvironment()) && !StringUtils.isEmpty(appender.getComponent())
			&& !StringUtils.isEmpty(appender.getVersion())
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("component")
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("environment")
			&& !jsonMapper.writeValueAsString(logMessage).toLowerCase().contains("version")) {
		HashMap<String, Object> message = new HashMap<String, Object>();
		message.put("Component", appender.getComponent());
		message.put("Version", appender.getVersion());
		message.put("Environment", appender.getEnvironment());
		message.put("Message", logMessage);
		message.put("Source", "");
		message.put("SequenceId", "");
		message.put("ScriptName", "");
		payload.put("LogMessage", message);
	}else{
		payload.put("LogMessage", logMessage);
	}

	payload.put("DateValue", sdf.format(new Date(loggingEvent.timeStamp)));
	
	if(appender.getAppendLogger()){
		payload.put("Logger", loggingEvent.getLoggerName());
	}
	
	if(appender.getAppendLogLevel() && loggingEvent.getLevel() != null){
		payload.put("Level", loggingEvent.getLevel().toString().toUpperCase());
	}

	return jsonMapper.writeValueAsString(payload);
}
 
開發者ID:ptv-logistics,項目名稱:Log4jALA,代碼行數:42,代碼來源:LoggingEventSerializer.java


注:本文中的org.apache.log4j.spi.LoggingEvent.getLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。