This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I have a class that contains debug(Object obj),warn(Object obj),... I want to print the class name that called these methods. It always prints the name of the class that contains debug, warn,info,... methods and not the name of the class that calls these methods.
The only way I can see of doing that is to pass the calling class (or class name) into your utility methods.
My advice would be not to use wrapper methods like these if you can possibly do without them. If you're convinced that you need to wrap the log4j calls you might be better off extending the Logger class and doing it that way. Note that I haven't looked into the practicality of doing that at all.
Joined: Aug 02, 2004
OK, you learn something new every day and here is my new thing for today:
Note that if performance is a key factor in your app and logging stays on in the production environment you will probably want to avoid this amount of processing on each logging call.