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


Java LoggingEvent.getProperties方法代碼示例

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


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

示例1: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public String format(LoggingEvent event)
{
    Map<String,Object> map = new TreeMap<String,Object>();
    map.put("timestamp",    new Date(event.getTimeStamp()));
    map.put("thread",       event.getThreadName());
    map.put("logger",       event.getLogger().getName());
    map.put("level",        event.getLevel().toString());
    map.put("message",      event.getRenderedMessage());

    if (event.getThrowableStrRep() != null) map.put("exception",    event.getThrowableStrRep());
    if (event.getNDC() != null)             map.put("ndc",          event.getNDC());
    if (tags != null)                       map.put("tags",         tags);

    if ((event.getProperties() != null) && ! event.getProperties().isEmpty())
    {
        map.put("mdc", event.getProperties());
    }


    if (processId != null)  map.put("processId", processId);
    if (hostname != null)   map.put("hostname", hostname);
    if (instanceId != null) map.put("instanceId", instanceId);

    if (enableLocation)
    {
        LocationInfo info = event.getLocationInformation();
        Map<String,Object> location = new TreeMap<String,Object>();
        location.put("className",  info.getClassName());
        location.put("methodName", info.getMethodName());
        location.put("fileName",   info.getFileName());
        location.put("lineNumber", info.getLineNumber());
        map.put("locationInfo", location);
    }

    return converterTL.get().convert(map);
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:38,代碼來源:JsonLayout.java

示例2: 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


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