我已经采取以下步骤尝试配置我的Akka应用程序的日志记录:
- 创建了一个application.conf文件,并将其放置在src/main/resources中。它看起来像:
akka {
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
loglevel = "INFO"
}
created a logback.xml file and placed it in src/main/resources. It looks like:
<configuration>
<appender name="FILE" class="ch.qos.logback.core.fileappender">
<File>./logs/akka.log</File>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%-5level] %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="FILE" />
</root>
</configuration>
我在我的.scala sbt构建文件中添加了以下内容:
libraryDependencies += "com.typesafe.akka" % "akka-slf4j" % "2.0.3",
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.9"
lazy val logback = "ch.qos.logback" % "logback-classic" % "1.0.9"
我尝试使用以下代码进行日志记录:
import akka.event.Logging
val log = Logging(context.system, this)
log.info("...")
但是,我只得到标准输出日志,没有日志文件被创建来保存这些日志。我错过了什么步骤?或者配置错误了吗?