Assuming that you did this inside a class:
... private static final Logger logger = LogManager.getLogger(SomeClass.class); ...
You can use the extra parameter to debug(), info(), error(), fatal(), etc. Like so:
try { throw new Exception("Ouch!"); } catch (Exception e) { // The second parameter takes a Throwable logger.error(e.getMessage(), e); }
Hope it helps.
- Mariano.
Hello,
I recently discovered the usage of log4j to show me Axis debuging information,
now I wonder what is the best way to be able to debug or log any errors from my server side classes,
so far I was only able to get understandable exceptions form my client code (obviously that's as easy as usual),
but in a distributed system like a webservice it's harder I suppose ?
When an error occurs in one of my server side classes (let's say an NullPointerException of some kind),
I only get the message "NullPointerException" in my console output, but no full stackTrace like on my client side.
So it's nearly impossible to find the error without knowing the class and method which threw the error.
Can I use the log4j properties file to send server side exception to my console or a file in some way,
or do I have to create a Logger on my server side, if so could anybody please give me a full example of how o do that ?
If there is another way of debugging my server side classes I would really like to get to know it :)
Thanks a lot in advance.
Steve