To get around the problems I was having with log4j in a clustered environment (multiple processes on one filesystem), I wrote a new appender that writes to the servlet log as if you called servletContext.log(...). Has anyone thought of doing this before? Hadn't seen much on the lists about it. I can submit the code if anyone is interested.
The catch is, somehow you have to initialize the appender with the ServletContext objcet. I arrived at a method "static public void setServletContext". Since we're already initializing log4j from a ServletContextListener, it's fairly trivial to call ServletLogAppender.setServletContext(...) from the context listener immediately after initializing log4j. [[Speaking of which, it might be nice to have a standard log4j context loader that you can just dump into web.xml and point at a properties file. We've implemented one trivially, but I'm sure lots of other folks already rolled their own too.]] Benefits: only one log file to worry about rolling and archiving; log4j events go right alongside app server events; and the app server should take responsibility for synchronizing writes or separating logs by process. Problems: Assumes a one-to-one mapping between classloaders and servlet contexts. It won't work inside EJBs, since EJBs are in a different classloader. The JMSAppender is the real long-term solution, although that requires someone to be listening for and recording the messages. But a ServletLogAppender will work nicely in a cluster of "pure" (non-EJB-ified) webapps. -- Bill -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>