How to print logs with the current class's name using Logback?

248 Views Asked by At

I have investigated past questions about that topic and still have no solution,

However, I want the logger to print the current class's name to the logs.

I mean the name of the whoever class that made the log message appear.

I found some solutions but unfortunately, none of them worked -

Instead of printing the class name - it's printed the actual logger name or "?" .

I'm using Logback and slf4j.

Those are the ways I already tried:

(at logback.xml logger's appender)

 <pattern>[%date{ISO8601}] [%level] [%logger] [%marker] [%thread] %logger{36} %logger{0}.%method:%L %c  %class{36}.%M %class{0}.%method:%L  %C %class - %msg MDC: {%mdc}%n</pattern>

What is the correct keyword for doing it?

Am I missing something?

0

There are 0 best solutions below