我搜索了很多但找不到合适的解决方案。有人可以帮助我吗?
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
stdout-loglevel = "WARNING"
actor {
debug {
receive = on
lifecycle = off
}
}
}
我已将以下内容添加到build.sbt
,希望其中一个解决问题:
libraryDependencies ++= Seq (
"com.typesafe.akka" %% "akka-actor" % "2.4.1", // akka actors
"ch.qos.logback" % "logback-classic" % "1.1.3", //logback, in order to log to file
"com.typesafe.scala-logging" % "scala-logging-slf4j_2.11" % "2.1.2",
"com.typesafe.akka" % "akka-slf4j_2.11" % "2.4.1", // needed for logback to work
// and my other dependencies
)
我尝试了logback.xml
找到的不同建议,其中最后一个是:
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/filename.log</file>
<encoder>
<pattern>%date %level %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>10</maxIndex>
<FileNamePattern>logs/filename.log.%i.gz</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>
</appender>
<root level="info">
<appender-ref ref="FILE" />
</root>
</configuration>
编辑:我的完整依赖关系如下(ps:我目前同时拥有lift
和salat
用于de /序列化,但这是一个不同的故事):
libraryDependencies ++= Seq (
"org.scala-lang" % "scalap" % scalaVersion.value,
"com.typesafe.akka" %% "akka-actor" % "2.4.1",
"ch.qos.logback" % "logback-classic" % "1.1.3",
"com.typesafe.scala-logging" % "scala-logging-slf4j_2.11" % "2.1.2",
"com.typesafe.akka" %% "akka-slf4j" % "2.4.1",
"com.github.sstone" %% "amqp-client" % "1.5",
"net.liftweb" %% "lift-json" % "2.6.2",
"net.liftweb" %% "lift-json-ext" % "2.6.2",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"com.novus" %% "salat" % "1.9.9"
)
答案 0 :(得分:3)
所以你使用的"com.novus" %% "salat" % "1.9.9"
取决于salat-util % 1.9.9
,org.slf4j % slf4j-api % 1.7.2
"com.typesafe.akka" %% "akka-slf4j" % "2.4.1"
。 Akka {{1}} depends于1.7.12。确保你需要整个salat包。可能你会找到一种只使用其中一部分的方法,或以不同的方式配置日志记录,或等待Salat开发人员的更新。
答案 1 :(得分:3)
@Mahdi:不确定你是否能够解决你的问题,但是我遇到了同样的问题并且发现了正确的版本
我的build.sbt中未包含"com.typesafe.akka" %% "akka-slf4j" % "2.4.0",
。
答案 2 :(得分:3)
解决这类问题的最佳方法是查看依赖关系树并弄清楚那里发生了什么,(非常重要的是maven
或sbt
)
查看您拥有多少个slf4j依赖项。 (我可以看到有冲突的依赖关系slf4j-api:1.6.0
,slf4j-api:1.7.2
,slf4j-api:1.7.12
)
sbt dependencyTree
[info] +-com.novus:salat_2.11:1.9.9 [S]
[info] | +-com.novus:salat-core_2.11:1.9.9 [S]
[info] | | +-com.novus:salat-util_2.11:1.9.9 [S]
[info] | | | +-org.scala-lang:scalap:2.11.5
[info] | | | | +-org.scala-lang:scala-compiler:2.11.5 [S]
[info] | | | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.3 [S]
[info] | | | | +-org.scala-lang.modules:scala-xml_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | | | +-org.scala-lang.modules:scala-xml_2.11:1.0.3 [S]
[info] | | | | +-org.scala-lang:scala-reflect:2.11.5 [S]
[info] | | | |
[info] | | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | | +-org.slf4j:slf4j-api:1.7.12
[info] | | | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.12)
[info] +-ch.qos.logback:logback-classic:1.1.3
[info] | +-ch.qos.logback:logback-core:1.1.3
[info] | +-org.slf4j:slf4j-api:1.7.12
[info] | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.12)
[info] | | +-org.mongodb:casbah-core_2.11:2.7.1 [S]
[info] | | +-com.github.nscala-time:nscala-time_2.11:1.0.0 [S]
[info] | | | +-joda-time:joda-time:2.3
[info] | | | +-org.joda:joda-convert:1.2
[info] | | |
[info] | | +-org.mongodb:casbah-commons_2.11:2.7.1 [S]
[info] | | | +-com.github.nscala-time:nscala-time_2.11:1.0.0 [S]
[info] | | | | +-joda-time:joda-time:2.3
[info] | | | | +-org.joda:joda-convert:1.2
[info] | | | |
[info] | | | +-org.mongodb:mongo-java-driver:2.12.1
[info] | | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | | +-org.slf4j:slf4j-api:1.7.12
[info] | | |
[info] | | +-org.mongodb:casbah-query_2.11:2.7.1 [S]
[info] | | | +-com.github.nscala-time:nscala-time_2.11:1.0.0 [S]
[info] | | | | +-joda-time:joda-time:2.3
[info] | | | | +-org.joda:joda-convert:1.2
[info] | | | |
[info] | | | +-org.mongodb:casbah-commons_2.11:2.7.1 [S]
[info] | | | | +-com.github.nscala-time:nscala-time_2.11:1.0.0 [S]
[info] | | | | | +-joda-time:joda-time:2.3
[info] | | | | | +-org.joda:joda-convert:1.2
[info] | | | | |
[info] | | | | +-org.mongodb:mongo-java-driver:2.12.1
[info] | | | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | | | +-org.slf4j:slf4j-api:1.7.12
[info] | | | |
[info] | | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | | +-org.slf4j:slf4j-api:1.7.12
[info] | | |
[info] | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | +-org.slf4j:slf4j-api:1.7.12
[info] | +-com.novus:salat-util_2.11:1.9.9 [S]
[info] | +-org.scala-lang:scalap:2.11.5
[info] | | +-org.scala-lang:scala-compiler:2.11.5 [S]
[info] | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.3 [S]
[info] | | +-org.scala-lang.modules:scala-xml_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | +-org.scala-lang.modules:scala-xml_2.11:1.0.3 [S]
[info] | | +-org.scala-lang:scala-reflect:2.11.5 [S]
[info] | |
[info] | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | +-org.slf4j:slf4j-api:1.7.12
[info] | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.12)
[info] +-com.typesafe.scala-logging:scala-logging-slf4j_2.11:2.1.2 [S]
[info] | +-com.typesafe.scala-logging:scala-logging-api_2.11:2.1.2 [S]
[info] | +-org.scala-lang:scala-reflect:2.11.5 [S]
[info] | +-org.slf4j:slf4j-api:1.7.12
[info] | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.12)
[info] +-net.liftweb:lift-json-ext_2.11:2.6.2 [S]
[info] | +-commons-codec:commons-codec:1.6
[info] | +-joda-time:joda-time:2.1 (evicted by: 2.3)
[info] | +-joda-time:joda-time:2.3
[info] | +-net.liftweb:lift-common_2.11:2.6.2 [S]
[info] | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.3 [S]
[info] | | +-org.scala-lang.modules:scala-xml_2.11:1.0.1 (evicted by: 1.0.3)
[info] | | +-org.scala-lang.modules:scala-xml_2.11:1.0.3 [S]
[info] | | +-org.slf4j:slf4j-api:1.6.0 (evicted by: 1.7.12)
[info] | | +-org.slf4j:slf4j-api:1.7.12
[info] | | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.12)
要知道使用的版本,
$ sbt dependencyList
[info] org.slf4j:slf4j-api:1.7.12
通过这种方式,您可以控制所需的版本以及要排除的版本,
例如。排除slf4j-api
使用的salat
版本
"com.novus" %% "salat" % "1.9.9" exclude("org.slf4j","slf4j-api")
将addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
添加到project/plugins.sbt
以使用sbt dependencyTree
。
https://github.com/jrudolph/sbt-dependency-graph#usage-instructions