java SLF4J 和 Logback 的依赖管理
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16660749/
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
Dependency management for SLF4J and Logback
提问by Evgeniy Dorofeev
I'd like to start using SLF4J with Logback. I read over Logback's online documentationand am now ready to add the JARs to my repo and try it out.
我想开始在 Logback 中使用 SLF4J。我阅读了 Logback 的在线文档,现在准备将 JAR 添加到我的存储库中并尝试一下。
But I'm at a loss! What JARs do I need? I downloaded that latest SLF4J (1.7.5) and expected to see somethinglike slf4j-logback.jar
, but don't see anything of the sorts. I've read that Logback contains a "native implementation" of SLF4J, but don't know exactly what this means, or if it also implies that I don't even need slf4j-api-1.7.5.jar
on the classpath.
但我不知所措!我需要什么 JAR?我下载了最新的 SLF4J (1.7.5) 并希望看到类似的东西slf4j-logback.jar
,但没有看到任何类似的东西。我读过 Logback 包含 SLF4J 的“本机实现”,但不知道这究竟意味着什么,或者是否还暗示我什至不需要slf4j-api-1.7.5.jar
在类路径上。
So I ask: to use the latest Logback (1.0.13), what JARs do I need? I took a look at the Maven central repo for logback 1.0.13and don't see any dependencies listed, so that didn't help me at all. Thanks in advance!
所以我问:要使用最新的 Logback(1.0.13),我需要什么 JAR?我查看了 logback 1.0.13的 Maven 中央存储库,但没有看到列出任何依赖项,所以这对我没有帮助。提前致谢!
回答by Evgeniy Dorofeev
You need to add logback-classic to your pom
您需要将 logback-classic 添加到您的 pom
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
it will transitively add the following two:
它将传递添加以下两个:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.13</version>
</dependency>
and
和
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
See https://logback.qos.ch/setup.html#mavenBuildfor more information.
有关更多信息,请参阅https://logback.qos.ch/setup.html#mavenBuild。