Spring supports logging in its usual plug and use format. To use Apache's log4j in a Spring-Maven environments:
- Add the log4j dependency to the pom
- In web.xml of the application define spring listener for log4j and its config location
- In the config location put in the appropriate properties file defining your loggers
The log4j.properties at the above link is fully commented to help you(and me) understand how to use a properties file to split your logs at a finer level.
I have realized that in order to utilize the full power of log4j it is important to understand and use log4j.properties. This can help you to isolate logs from different part of of your application- something that can be really handy when you are trying to pin-point the source of trouble in a large system. The bigger and more distributed your system becomes, more important and useful logging appears.
As usual, I have focussed only on the practical aspects. For knowing more about log4j, see:
No comments:
Post a Comment