I think I have an idea why the ServletContextLogAppender (in logging-log4j-sandbox) isn't working properly with multiple repositories performing logging services for both the server and individual apps (and, actually, this isn't solved by adding log4j.jar to WEB-INF/lib either).
The way logging now works for Tomcat-5.5.x is to use commons-logging + some logging implementation; namely Log4j. So, when I start up and initialize things, I create a few loggers. Among them, I create a logger for each context running in the app. Here's an example...
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp]
The above is Tomcat's naming scheme used for any given context in the server. This logger is for a context named "/myapp".
Anyway, the above logger is initially created in the default repository. In the "/myapp" context, I use my InitShutdownController to install the ContextJNDISelector (actually, it just makes an attempt in the case that it wasn't already done). So, at application startup, the application will be registered to log to the "myapp" repository, rather than the default one. Now, I expect all my applications loggers to do that, but then I found the following in my log file....
...
...
log4j:INFO Creating new logger [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp]] in repository [default].
...
...
log4j:INFO Creating new logger [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/myapp]] in repository [myapp].
...
...
Notice that the first logger was created in the "default" repository where the second was created in the "myapp" repository. So, before I install the selector, the "/myapp" context logger is registered in the default repository. However, after I install the repository selector, a new "/myapp" logger is registered in the "myapp" repository. This being the case, and the fact that the "myapp" repository has its own config file, the "/myapp" context logger that I have access to in the "myapp" repository is disconnected from the original appender it was registered to which was supposed to log to ${catalina.home}/logs/localhost_myapp.log.
So, the purpose the ServletContextLogAppender is completely defeated in the multi-repository environment. This might not seem like a big deal to some who don't care about the ServletContextLogAppender, but there is a bigger problem here. It fundamentally breaks the ServletContext.log() mechanism of the servlet spec (which is what the ServletContextLogAppender uses under the covers to pass logging to the container's context log in the first place) causing it to be completely ineffectual. Granted, ServletContext.log() is pretty rudimentary and ought not be used in lieu of a more sophisticated logging implementation, but we shouldn't be breaking it.
Is the a way around this? Is it possible to avoid creating the "/myapp" context logger instance in the "myapp" repository if it has already been created in the "default" repository? Might there be a registration mechanism of loggers which shouldn't be created if they already exist in another repository? I'm not sure if that is a good idea or not. Just throwing this out there for comment. Other suggestions?
Jake
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]