This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
Hello, As per my requirement, I need to use something like MyAppLogger in all my class to get log4j logger. As suggested in log4j Complete manual, I decided to use Wrapper class to get log4j Logger. Please look at my Wrapper class below.
Now, the next requirement is to prefix "Timestamp, threadId, Class name, Method name" to the actual log message. I configured PatternLayout in log4j.xml config file as mentioned below
The result is expected to show up Class name and method name where logging message is created. But what happens here is, as I use logger wrapper, the class name and method name is always com.logger.test.MyAppLogger.debug/info/warn/error. This is not the behavior which I need. How could I correct ? Should I remove wrapper and extend log4j Logger class? What would be the best approach? Please advise me.
I'm not sure why you are using wrapper, but looking at the complete log4j manual that you mention...you are not using a critical part of what is suggested.
The mysterious FCQN variable, declared at the start of MyLogger class, helps log4j to obtain the correct localization information...without it log4j will...think that MyLogger is the caller instead of the class which really invoked a MyLogger instance.
Then the usage of the log method with FQCN is shown. Partial Example :
Edit: typo in the code from complete manual, I could not copy from the pdf.
posted 8 years ago
Thank you so much!! I missed a VERY important point.
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad: