[ginp-users] log4j is now working
Brought to you by:
burchbri,
dougculnane
From: Brian B. <Br...@Pi...> - 2006-03-25 12:12:57
|
Each time I started my tomcat server with the ginp webapp deployed, I noticed the following message in ../logs/catalina.out... log4j:WARN No appenders could be found for logger (net.sf.ginp.config.GinpEnv) I've spent quite a lot of time working with log4j over the years, so I decided to investigate. The project currently ships with /src/log4j.properties, but this file is not much more than a standard log4j sample and does not work with the existing v0.23 source. The as-shipped log4j.properties file doesn't work because the source code is following the recommended convention of using a logger that is derived from the fully-qualified java class names. Unfortunately, the log4j configuration file doesn't say how these logging events should be handled. I've attached a copy of my own log4j.properties, which is working quite well with ginp and has resolved the startup error completely. My changes are as follows: 1. Define a rootLogger which sets the system-wide logging capture level AND an appender which will collect any messages not handled explicitly. (So far, I've not seen any stray messages on my system). I've set this to capture DEBUG (and higher) events, but INFO or even WARN would be better on a production system. 2. Define a logger for net.sf.ginp... this ensures that log events from all ginp components will be handled by the same set of appenders. I have specified two active appenders - one to capture INFO (and above) messages and the other to capture all levels of messages. 3. Define two DailyRollingFileAppender instances for ginp events. I've given them meaningful names and filenames. They write to the tomcat logs directory using the ${catalina.home} property, which is automatically maintained by tomcat. I use the Threshold property to select the event-levels-of-interest to each appender, but am puzzled by the fact that they don't work as described. I haven't had time to investigate yet, but at least I get all ginp messages logged! 4. I've defined a syslog appender for completeness, but haven't activated it in this configuration. I hope you find this useful in your own installations. Regards, Brian |