本文介绍了SLF4J和Logback的依赖性管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始将SLF4J与Logback结合使用.我阅读了Logback的在线文档,现在准备将JAR添加到我的仓库中并尝试一下.

I'd like to start using SLF4J with Logback. I read over Logback's online documentation and am now ready to add the JARs to my repo and try it out.

但是我很茫然!我需要什么JAR?我下载了最新的SLF4J(1.7.5),希望看到类似的东西,但看不到任何类似的东西.我已经了解到Logback包含SLF4J的本机实现",但不确切知道这是什么意思,或者它是否还意味着我甚至不需要在类路径上使用slf4j-api-1.7.5.jar.

But I'm at a loss! What JARs do I need? I downloaded that latest SLF4J (1.7.5) and expected to see something like 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.

所以我问:要使用最新的Logback(1.0.13),我需要什么JAR?我看了一下Maven中央存储库用于logback 1.0.13 ,并且看不到任何依赖项,因此这对我没有任何帮助.预先感谢!

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.13 and don't see any dependencies listed, so that didn't help me at all. Thanks in advance!

推荐答案

您需要将logback-classic添加到pom

You need to add logback-classic to your 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>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
</dependency>

请参见 https://logback.qos.ch/setup.html#mavenBuild 有关更多信息.

这篇关于SLF4J和Logback的依赖性管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 20:08