Our Akka project depends on some other non akka code. From within this code our way to get a logger is by calling org.slf4j.LoggerFactory.getLogger(ThisClass.class)
I would like to have the real time and real thread when and where the event took place, included in the log print, so I fetch the values of akkaTimestamp and sourceThread, as following:
log4j.appender.console.layout.ConversionPattern=[%-5p] [%X{akkaTimestamp}] [%X{sourceThread}] %c{5}: %m%n
Problem is that these values, which are extracted from the MDC, are not available in the prints which were dispatched from the non-akka loggers.
Here they say
It will probably be a good idea to use the sourceThread MDC value also in non-Akka parts of the application in order to have this property consistently available in the logs.
But they never say how /:
MDC.put("sourceThread", Thread.currentThread().getName())
either in the actor prior to calling the non-actor code, or is some cases it will be the first thing I do in the non-actor code. If you can access the akkaTimestamp from actor's context then you could set this also. – Vasos