My class has an Id associated with it when instantiated. I want to be able to log that object level information similar to MDC/PatternLayout. Not sure if this would work if I put it in MDC because I do not know that one thread will execute one method of an object. Is there a way to do it in log4j?
2015-10-01 12:52:03,117 [priority="INFO", thread="ForkJoinPool-1-worker-7", myObjectId="3838901231"] com.company.projectA.classA - initialization started
In the above example myObjectId is for each object that should be printed without writing it in the logger.info() statements.