I have tried the below steps to configure logging for my akka system:
1.Created both application.conf and logback.xml file and put them in the src/main/resources directory.
2.application.conf file looks like:-
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
logging-filter="akka.event.slf4j.Slf4jLoggingFilter"
log-config-on-start = on
loglevel = "DEBUG"
}
3.logback.xml file looks like:-
<?xml version="1.0" encoding="UTF-8"?>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<encoder>
<pattern>%X{akkaTimestamp} %-5level[%thread] %logger{0} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>/Users/deepak/work/logs/akka.log</file>
<append>true</append>
<encoder>
<pattern>%date{yyyy-MM-dd} %X{akkaTimestamp} %-5level[%thread] %logger{1} - %msg%n</pattern>
</encoder>
</appender>
<logger name="akka" level="DEBUG" />
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
4.sbt build dependencies:-
libraryDependencies += "com.typesafe.akka" % "akka-slf4j_2.11" % "2.4.14"
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3" % Test
5.Akka Version="2.4.14"
6.After building the jar file, i checked the application.conf and logback.xml files are present inside it. So, i don't think it is any classpath issue.
7.My actor mixes with the ActorLogging trait. But when i run the jar file i am not able to see the logs
import akka.actor.{Actor, ActorLogging}
class Reader extends Actor with ActorLogging{
override def receive = {
case _ =>log.info("Reader")
}
}
Please, help here. I am not able figure out the issue