Reputation: 1608
I have tried using log4j and slf4j with akka in scala and I am able to get log files. Can I achieve the same thing without using any external api other than akka APIs? By using akka.event.Logging I am able to print logs in console, but I want to print it in a file.
I have already tried setting log4j.properties file for my project in classpath and its not working when I am using akka.event.Logging.
Please suggest.
Upvotes: 0
Views: 1168
Reputation: 436
Accordingly to this http://doc.akka.io/docs/akka/current/java/logging.html you have 3 options:
akka.event.Logging$DefaultLogger
(to stdout, not for production)akka.event.slf4j.Slf4jLogger
(logger by akka for SLF4J)Your case is 2 or 3 (you use log4j.properties
).
Therefore you should properly configure file log4j.properties
for output in file.
And
akka.event.Logging
, for example: Logging.getLogger(system.eventStream(), "my.string")org.slf4j.LoggerFactory.getLogger(...)
Your case is 2, if you use in your akka config something like this:
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "DEBUG"
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}
Upvotes: 1