我已经搜索了很多,但是找不到有效的解决方案。有人可以帮我吗?

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:我目前同时具有liftsalat进行de / serialization,但这是一个不同的故事):

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"
)

最佳答案

因此,您使用的"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"。 1.7.12上的Akka depends。确保您需要整个礼拜套餐。可能您会找到一种仅使用其中一部分的方法,或者以其他方式配置日志记录,或者等待Salat开发人员进行更新。

关于scala - 登录到Scala/akka中的文件:ClassNotFoundException:akka.event.slf4j.Slf4jLoggingFilter,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34133715/

10-15 11:14