我的 logback.xml 与 Akka 有什么问题?
What's wrong with my logback.xml with Akka?
为什么我的 logback 日志被 Akka 阻塞了?如果我单独留下 Akka 配置但删除我的 logback.xml 文件,无论默认设置是什么,它都会出现 w/o 问题。我的 logback.xml 文件中是否存在配置错误?
logback.xml
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>
</configuration>
application.conf
akka {
loglevel = "ERROR"
stdout-loglevel = "ERROR"
loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = akka.remote.RemoteActorRefProvider
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
}
}
Build.scala(剪辑):
lazy val root = project.in(file("."))
.settings(basicSettings: _*)
.settings(libraryDependencies ++=
dep_compile(
typesafe_config, logback, akka_actor, akka_remote, akka_slf4j) ++
dep_test(scalatest)
)
当某些东西尝试记录错误时,我得到:
error while starting up loggers
akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due to [akka.event.Logging$LoggerInitializationException: Logger log1-Slf4jLogger did not respond with LoggerInitialized, sent instead [TIMEOUT]]
at akka.event.LoggingBus$$anonfun$$anonfun$apply.applyOrElse(Logging.scala:116)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.applyOrElse(Logging.scala:115)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
at scala.util.Failure$$anonfun$recover.apply(Try.scala:185)
at scala.util.Try$.apply(Try.scala:161)
...
Caused by: akka.event.Logging$LoggerInitializationException: Logger log1-Slf4jLogger did not respond with LoggerInitialized, sent instead [TIMEOUT]
at akka.event.LoggingBus$class.akka$event$LoggingBus$$addLogger(Logging.scala:185)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.apply(Logging.scala:114)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.apply(Logging.scala:113)
at scala.util.Success$$anonfun$map.apply(Try.scala:206)
at scala.util.Try$.apply(Try.scala:161)
at scala.util.Success.map(Try.scala:206)
at akka.event.LoggingBus$$anonfun.apply(Logging.scala:113)
... 36 more
您在配置中使用旧记录器 class。修复方法如下:
Akka (2.3.0) fails to load Slf4jEventHandler class with java.lang.ClassNotFoundException
为什么我的 logback 日志被 Akka 阻塞了?如果我单独留下 Akka 配置但删除我的 logback.xml 文件,无论默认设置是什么,它都会出现 w/o 问题。我的 logback.xml 文件中是否存在配置错误?
logback.xml
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>
</configuration>
application.conf
akka {
loglevel = "ERROR"
stdout-loglevel = "ERROR"
loggers = ["akka.event.slf4j.Slf4jLogger"]
actor {
provider = akka.remote.RemoteActorRefProvider
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
}
}
Build.scala(剪辑):
lazy val root = project.in(file("."))
.settings(basicSettings: _*)
.settings(libraryDependencies ++=
dep_compile(
typesafe_config, logback, akka_actor, akka_remote, akka_slf4j) ++
dep_test(scalatest)
)
当某些东西尝试记录错误时,我得到:
error while starting up loggers
akka.ConfigurationException: Logger specified in config can't be loaded [akka.event.slf4j.Slf4jLogger] due to [akka.event.Logging$LoggerInitializationException: Logger log1-Slf4jLogger did not respond with LoggerInitialized, sent instead [TIMEOUT]]
at akka.event.LoggingBus$$anonfun$$anonfun$apply.applyOrElse(Logging.scala:116)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.applyOrElse(Logging.scala:115)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
at scala.util.Failure$$anonfun$recover.apply(Try.scala:185)
at scala.util.Try$.apply(Try.scala:161)
...
Caused by: akka.event.Logging$LoggerInitializationException: Logger log1-Slf4jLogger did not respond with LoggerInitialized, sent instead [TIMEOUT]
at akka.event.LoggingBus$class.akka$event$LoggingBus$$addLogger(Logging.scala:185)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.apply(Logging.scala:114)
at akka.event.LoggingBus$$anonfun$$anonfun$apply.apply(Logging.scala:113)
at scala.util.Success$$anonfun$map.apply(Try.scala:206)
at scala.util.Try$.apply(Try.scala:161)
at scala.util.Success.map(Try.scala:206)
at akka.event.LoggingBus$$anonfun.apply(Logging.scala:113)
... 36 more
您在配置中使用旧记录器 class。修复方法如下:
Akka (2.3.0) fails to load Slf4jEventHandler class with java.lang.ClassNotFoundException