The encoder pattern in logback.xml
like
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
allows to enhance logging messages with context information like the current thread and the class name. Is there a possibility to display the identity hash code (returned by System.identityHashcode(Object)
) in the messages? I wouldn't mind a custom extension in form of a subclass, even though a configuration per class or package would be nice. I just have no idea where to start.
I'm aware that I can work around the problem by adding System.identityHashcode
to each log message. The idea for this question is to provide a configurable approach.
I'm accessing logback-classic
1.2.3 through SLF4J API 1.7.25, but wouldn't mind to upgrade to a 1.8.x snapshot.