我刚刚将我的项目从 JUL (java.util.logging) 切换到 SL4J。一切都很好,我只有一个不满:记录时,时间戳与我不太相关,例如:
2 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Context initialized.
703 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Connection with database succesful.
1144 [pool-2-thread-1] INFO com.lexit.server.ServerContext - External emails will be sent
1144 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Alarms will be sent fr
1146 [pool-2-thread-1] INFO java.lang.Class - Adding reccuring timer with id: 1234567
如何配置 SL4J 以获得更相关的时间戳(例如 2012 年 3 月 8 日下午 5:38:00)??
最佳答案
这是 SLF4J 的 SimpleLogger
发出的日志格式.
亲自查看: http://www.slf4j.org/apidocs/org/slf4j/impl/SimpleLogger.html
SimpleLogger
是当您尚未将 SLF4J“桥接”jar 之一添加到类路径时使用的记录器。确保将 slf4j-jdk14-x.x.x.jar(JUL 桥)添加到类路径中,以便将 SLF4J 配置为桥接到 JUL。
关于java - SL4J 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9626332/