更新时间:2023-09-13 09:48:40
您应该使用SLF4J + Logback进行记录。
You should use SLF4J+Logback for logging.
它提供了一些简洁的功能,如参数化消息和(与公共日志记录相比)映射诊断上下文(MDC, javadoc ,文档)。
It provides neat features like parametrized messages and (in contrast to commons-logging) a Mapped Diagnostic Context (MDC, javadoc, documentation).
使用SLF4J使得日志记录后端可以非常优雅的方式进行交换。
Using SLF4J makes the logging backend exchangeable in a quite elegant way.
此外,SLF4J 支持将其他日志记录框架桥接到您将使用的实际SLF4J实现,以便第三方软件的日志记录事件将显示在统一日志中 - 除了java.util.logging无法以与其他日志框架相同的方式进行桥接。
Additionally, SLF4J supports bridging of other logging frameworks to the actual SLF4J implementation you'll be using so logging events from third party software will show up in your unified logs - with the exception of java.util.logging that can't be bridged the same way that other logging frameworks are.
Bridging jul is explained in the javadocs of SLF4JBridgeHandler.
我有一个在几个项目中使用SLF4J + Logback组合的非常好的经验和LOG4J开发几乎停滞不前。
I've had a very good experience using the SLF4J+Logback combination in several projects and LOG4J development has pretty much stalled.
SLF4J还有以下缺点:
SLF4J has the following remaining downsides: