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


Java ILoggingEvent.getMDCPropertyMap方法代碼示例

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


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

示例1: matches

import ch.qos.logback.classic.spi.ILoggingEvent; //導入方法依賴的package包/類
protected boolean matches(ILoggingEvent event) {
	if(loggerName != null) {
		if(!event.getLoggerName().equals(loggerName)) {
			return false;
		}
	}
	if(level != null) {
		if(!event.getLevel().isGreaterOrEqual(level)) {
			return false;
		}
	}
	Map<String, String> mdcPropertyMap = event.getMDCPropertyMap();
	String value = mdcPropertyMap.get(key);
	if(value != null) {
		if(matcher.matches(value)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:skjolber,項目名稱:json-log-domain,代碼行數:21,代碼來源:MdcMatcher.java

示例2: mdcAppender

import ch.qos.logback.classic.spi.ILoggingEvent; //導入方法依賴的package包/類
private void mdcAppender(StringBuilder sb, ILoggingEvent iLoggingEvent)
{
    Map<String, String> mdc = iLoggingEvent.getMDCPropertyMap();
    if ( mdc != null )
    {
        mdc.forEach((k, v) ->
        {
            if ( !isNativeKey(k) )
            {
                appendKeyValueAndEscape(sb, k, v);
            }
        });
    }
}
 
開發者ID:BatchLabs,項目名稱:escalog,代碼行數:15,代碼來源:LogFmtLayout.java

示例3: append

import ch.qos.logback.classic.spi.ILoggingEvent; //導入方法依賴的package包/類
@Override
protected void append(ILoggingEvent event) {
	if(!("info".equalsIgnoreCase(event.getLevel().toString()) || "error".equalsIgnoreCase(event.getLevel().toString())) )
		return;
	// TODO Auto-generated method stub
	org.apache.log4j.spi.LoggingEvent a;
	List<LogItem> logItems = new ArrayList<LogItem>();
	LogItem item = new LogItem();
	logItems.add(item);
	item.SetTime((int) (event.getTimeStamp() / 1000));
	item.PushBack("time", formatter.format(new Date(event.getTimeStamp())));
	item.PushBack("level", event.getLevel().toString());
	item.PushBack("thread", event.getThreadName());
	item.PushBack("location", event.getLoggerName());
	item.PushBack("user", "登錄用戶");
	item.PushBack("ip", "登錄用戶");
	StringBuilder sbuf = new StringBuilder(event.getFormattedMessage());
	if (event.getThrowableProxy() != null) {
		throwableRenderer.render(sbuf, event);
	}
	
	Map properties = event.getMDCPropertyMap();
	if (properties.size() > 0) {
		Object[] keys = properties.keySet().toArray();
		Arrays.sort(keys);
		for (int i = 0; i < keys.length; i++) {
			item.PushBack(keys[i].toString(), properties.get(keys[i]).toString());
		}
	}
	
	item.PushBack("message", sbuf.toString());
	producer.send(projectConfig.projectName, logstore, topic, null, logItems);
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:34,代碼來源:LoghubAppender.java


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