当前位置: 首页>>代码示例>>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;未经允许,请勿转载。