Akka Actor logging of line numbers

We are using Akka 2.4.19 with Scala 2.12.12. If I configure logback to log line numbers I only see:


which is a class in the akka library. How do I get the real location of the issued log statement or what am I doing wrong?

See also https://stackoverflow.com/questions/64355775/how-to-log-filename-and-linenumber-in-akka-classic-actor

I do use the following pattern:

<pattern>%d{HH:mm:ss.SSS} %-5level [%thread] [%logger] [%F:%L] [%mdc{akkaSource:-}] %msg [%mdc]%n</pattern>

Patrik answered:
"…Short answer is that Akka’s logging is asynchronous so Slf4jLogger is expected. You can create your own slf4j Logger with the LoggerFactory and then you will see your own source code. "

I am not sure if I understand what and why to do. Logback is a backend for Slf4j. Do we have to switch to Slf4j Impl now? And why?

Akka’s internal logging is asynchronous, meaning that log messages emitted via the akka.event.LoggingAdapter is sent to the actor Slf4jLogger. It’s the Slf4jLogger actor that will call the slf4j.Logger method and therefore the thread and source line number is from the Slf4jLogger actor.

That is by design and there is no work around for that for Akka’s internal logging.

For your own logging you don’t have to use Akka’s LoggingAdapter. You can log directly to your own slf4j.Logger.

More info at https://doc.akka.io/docs/akka/current/logging.html#slf4j

Ok understood, thank you very much for the explanation.