the3rdNotch
the3rdNotch

Reputation: 667

Akka SLF4J and logback in Scala

I am trying to set up some basic logging for my akka actor system, but so far am only getting the standard logs and none of my added logs or an output file. I have followed along with the akka docs for logging and have set up the following:

I do not receive and messages of the failure from the standard logging, and I haven't been able to find additional solutions much different from what I already have. I have tried the suggestions in this question. It seemed to be the same issue I'm having, but the suggestions did not work. Have I missed a step or configured something wrong?

Upvotes: 8

Views: 3685

Answers (1)

yǝsʞǝla
yǝsʞǝla

Reputation: 16412

Everything looks correct except for the missing akka.logging-filter setting. Here how it should look like:

akka {
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}

Here is a project with the same setup that has logging working: application.conf and logback.xml.

Explanation from the docs:

You need to enable the Slf4jLogger in the loggers element in the Configuration. Here you can also define the log level of the event bus. More fine grained log levels can be defined in the configuration of the SLF4J backend (e.g. logback.xml). You should also define akka.event.slf4j.Slf4jLoggingFilter in the logging-filter configuration property. It will filter the log events using the backend configuration (e.g. logback.xml) before they are published to the event bus.

and

Warning! If you set the loglevel to a higher level than "DEBUG", any DEBUG events will be filtered out already at the source and will never reach the logging backend, regardless of how the backend is configured.

which you took care of already.

Upvotes: 10

Related Questions