如何从 scala/sbt/slf4j 项目中排除公共日志记录? [英] How to exclude commons-logging from a scala/sbt/slf4j project?

查看:30
本文介绍了如何从 scala/sbt/slf4j 项目中排除公共日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 scala/sbt 项目使用 grizzled-slf4j 和 logback.第三方依赖项使用 Apache Commons Logging.

My scala/sbt project uses grizzled-slf4j and logback. A third-party dependency uses Apache Commons Logging.

对于 Java/Maven,我会使用 jcl-over-slf4j 和 logback-classic,这样我就可以使用 logback 作为统一的日志记录后端.

With Java/Maven, I would use jcl-over-slf4j and logback-classic so that I can use logback as the unified logging backend.

我还将消除第三方库让 sbt 引入的 commons-logging 依赖项.我在 Maven 中执行以下操作(http://www.slf4j.org/faq.html# excludeJCL):

I would also eliminate the commons-logging dependency that the third-party lib would let sbt pull in. I do the following in Maven (which is recommended by http://www.slf4j.org/faq.html#excludingJCL):

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>

问题是,如何对 sbt 做同样的事情?

And the question is, how to do the same with sbt?

推荐答案

Heiko 的方法可能会奏效,但不会导致第三方库的任何依赖项都无法下载.如果您只想排除特定的一项,请使用 exclude.

Heiko's approach will probably work, but will lead to none of the dependencies of the 3rd party lib to be downloaded. If you only want to exclude a specific one use exclude.

libraryDependencies += "foo" % "bar" % "0.7.0" exclude("org.baz", "bam")

... excludeAll( ExclusionRule(organization = "org.baz") ) // does not work with generated poms!

这篇关于如何从 scala/sbt/slf4j 项目中排除公共日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆