I am planning to implement logging into a web application that I am currently working on but I am struggling with some of the details. What is the best way to go about logging a Java web application?
Specifically;
- Where does the configuration file go in .war package file?
- Where do people log to, relative or absolute path flat file, or a database?
- Does Log4J logging go directly into the application server log file automatically or is that something you have to set up? In this case I am using Tomcat, but I often use Jrun.
- Any other gotchas I should be aware of for web application logging?
Currently I am using Log4J but I imagine that the best practices would apply universally to all logging implementations.
EDIT:
One addition to the questions up top.
- Where do you initilize the log configuration?
In a traditional app, I do this at the entry point;
DOMConfigurator.configureAndWatch('log4j.xml');
What would the web application equivalent be?
I place my configuration on the default package: src/
and log to files using the ${catalina.home} system property:
log4j.appender.???.file=${catalina.home}/logs/system.log