我正在尝试在我的 sbt 项目中使用 logback.xml。 我添加了以下依赖项:
"ch.qos.logback" % "logback-classic" % "1.2.3"
我创建了一个登录.xml并将其定位在:
/src/main/resources
当我在 Intellij 上运行它时,有时它可以工作,有时它不起作用。 当我运行 jar(不是 Uber jar(时,它总是不起作用:
SLF4J: Found binding in [jar:file:/Users/***/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/***/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
我相信该问题与类路径问题有关,排除了SLF4J,明确指定了logback.xml路径,但没有!
请帮忙!
我从所有依赖项和插件中排除了"org.slf4j",除了"ch.qos.logback",并且我避免在类路径中使用多个slf4j:
。.map( _ exclude("org.slf4j", "*")) ++ Seq("ch.qos.logback" % "logback-classic" % "1.2.3")