我无法从MDC键值设置简单的打印日志 什么都没有出现在我的任何日志上,不知道我缺少什么配置。有人有提示吗?
这里是我的过滤器
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain fc)
throws IOException, ServletException {
try {
String MDCData = String.format("[idDm=%s]",Util.getIdDm((HttpServletRequest)request));
MDC.put("mdcData", MDCData);
fc.doFilter(request, response);
}finally {
MDC.clear();
}
}
这里application.yml有这个
logging:
pattern: '%X{mdcData}%5p'
level:
org.springframework.security: DEBUG
org.springframework.web.filter.CommonsRequestLoggingFilter: DEBUG
org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask: FATAL
答案 0 :(得分:0)
尝试像这样将图案放在logging.pattern.level
下
logging:
pattern:
level: '%X{mdcData}%5p'
level:
org.springframework.security: DEBUG
org.springframework.web.filter.CommonsRequestLoggingFilter: DEBUG
org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask: FATAL