可以选择使用 log4j
来格式化日志编号
1| INFO | 2017-07-12 09:17:37 | MainApplication.java | 28 | hello world
2| INFO | 2017-07-12 09:17:37 | MainApplication.java | 28 | hello world
SERIAL Num. | INFO | 2017-07-12 09:17:37 | MainApplication.java | 28 | hello world
我现在的格式是这样的
%5p | %d{yyyy-MM-dd HH:mm:ss} | %-20.30F | %L | %m%n
最佳答案
您可以使用%sn
打印log4j2
中的事件序列号。
Includes a sequence number that will be incremented in every event. The counter is a static variable so will only be unique within applications that share the same converter Class object.
但是log4j 1.x
中没有类似的配置
关于java - log4J 序列日志号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45049894/