微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

scala – Akka演员记录不写文件

我试图登录一个文件,而不是stdout.

我的application.conf(在src / main / resources /)中:

akka {
  event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
  loglevel = "DEBUG"
}

logback.xml(在src / main / resources /)中:

<configuration>

    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>log/app.log</file>
        <append>true</append>
        <encoder>
            <pattern>%date{yyyy-MM-dd} %X{akkaTimestamp} %-5level[%thread] %logger{1} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="FILE"/>
    </root>
</configuration>

创建演员系统:

val conf: Config = ConfigFactory.load()
val system = ActorSystem("Process",conf)

最后,实际记录:

class Processor() extends Actor with ActorLogging {
   def receive = {
      case Start =>
         log.info("Started")
   }
}

但是,当运行应用程序时,我得到stdout的登录

[info] Running com.imgzine.analytics.apps.ProcessEvents
[DEBUG] [06/02/2014 09:28:53.356] [run-main] [EventStream(akka://Process)] logger log1-Logging$DefaultLogger started
[DEBUG] [06/02/2014 09:28:53.358] [run-main] [EventStream(akka://Process)] Default Loggers started
[INFO] [06/02/2014 09:28:53.389] [Process-akka.actor.default-dispatcher-4] [akka://Process/user/processor] Started
[DEBUG] [06/02/2014 09:28:54.887] [Process-akka.actor.default-dispatcher-4] [EventStream] shutting down: StandardOutLogger started

在log / app.log里面,我发现:

2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Registering Scala Conversions.
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Deserializers for Scala Conversions registering
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Serializers for Scala Conversions registering
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Setting up OptionSerializer
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Setting up ScalaProductSerializer
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Setting up ScalaCollectionSerializer
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Setting up ScalaRegexSerializers
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Hooking up scala.util.matching.Regex serializer
2014-06-02  DEBUG[ProcessEvents-akka.actor.default-dispatcher-2] c.m.c.c.c.s.RegisterConversionHelpers$- Reached base registration method on MongoConversionHelper.

有任何想法吗?

解决方法

如果您使用Akka 2.3.3作为回应我的评论所述,那么您的日志记录周围的配置已过期(使用旧的日志记录配置设置).尝试用以下替换您的日志配置:

akka {
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
}

如果这不行,让我知道,我会建议另一个解决方案.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐