如何为所有级别的log4j
输出添加唯一ID(以跟踪多线程计算机上哪些请求属于一起)?
log4j.appender.console.layout.ConversionPattern = ???
答案 0 :(得分:1)
在多线程计算机中,您应该使用threadID / thread-Name来跟踪日志。
来自log4j doc,
For example, the PatternLayout with the conversion pattern "%r [%t] %-5p %c - %m%n"
will output something akin to:
176 [main] INFO org.foo.Bar - Located nearest gas station.
如果您对转化模式有更多了解,请阅读here。