Java slf4j-log4j12 和 log4j-over-slf4j 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31044619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between slf4j-log4j12 and log4j-over-slf4j
提问by Kumar Sambhav
What's the difference between slf4j-log4j12 and log4j-over-slf4jand when should each be used?
slf4j-log4j12 和log4j-over-slf4j之间有什么区别,应该什么时候使用?
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.12</version>
</dependency>
采纳答案by Puce
log4j-over-slf4j
Use this if your code or some libraries you are using uses Log4j directly, but you want to use a different SLF4J binding than Log4j. It will route the Log4j API calls to SLF4J to the binding you choose. You need to remove the Log4j library from your classpath and replace it with this dependency.
如果您的代码或您使用的某些库直接使用 Log4j,但您想使用与 Log4j 不同的 SLF4J 绑定,请使用此选项。它将对 SLF4J 的 Log4j API 调用路由到您选择的绑定。您需要从类路径中删除 Log4j 库并将其替换为此依赖项。
slf4j-log4j12
Use this if you want to use the Log4j 1.2 binding for SLF4J.
如果您想对 SLF4J 使用 Log4j 1.2 绑定,请使用此选项。
You shouldn't use both of these libraries at the same time.
你不应该使用这两个库在同一时间。
Please note also that Log4j 2 has been released.
另请注意,Log4j 2 已发布。