简体   繁体   English

在Akka中设置日志记录级别

[英]Set logging level in Akka

I have developed a financial data distribution server with Akka, and I want to set logging level for the application. 我用Akka开发了一个财务数据分发服务器,我想为应用程序设置日志记录级别。 The documentation at akka.io is sketchy at the best; akka.io上的文档是最好的粗略的; they say there is no more "logging" in Akka and logging is defined through event handlers now. 他们说Akka中没有“日志记录”,现在通过事件处理程序定义了日志记录。 There is also an example of event handler configuration, including logging level: 还有一个事件处理程序配置示例,包括日志记录级别:

akka {
  event-handlers = ["akka.event.EventHandler$DefaultListener"]
  event-handler-level = "INFO"
}

I did that, but though akka.conf is successfully loaded, logging still appears to be at "DEBUG" level. 我这样做了,但是虽然成功加载了akka.conf,但日志记录仍然处于“DEBUG”级别。 What can be the problem there? 那可能是什么问题?

It appears that Akka uses slf4j/logback logging with default configuration. 似乎Akka使用默认配置的slf4j / logback日志记录。 So the (never documented) solution would be to put eg the following logback.xml in your classpath: 所以(从未记录)解决方案是将以下logback.xml放在类路径中:

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="false" debug="false">
  <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>[%4p] [%d{ISO8601}] [%t] %c{1}: %m%n</pattern>
    </encoder>
  </appender>
  <!-- you can also drop it completely -->
  <logger name="se.scalablesolutions" level="DEBUG"/> 
  <root level="INFO">
    <appender-ref ref="stdout"/>
  </root>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM