This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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.