logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorbjørn Ravn Andersen <nospam0...@gmail.com>
Subject Re: Improving log4j so it can easily be used with servlet logging
Date Mon, 31 May 2010 20:43:21 GMT
Den 30/05/10 21.34, Ralph Goers skrev:
> Wouldn't it make more sense for the LoggerContext to have a reference to the ServletContext?
The Appender could then do
> if (getContext().getServletContext() != null) {
>    getContext().getServletContext().log(event.getFormattedMessage());
> }
I do not know.  I am unfamiliar with what the LoggerContext provides.  
Are you suggesting that for each and every possible sub-context you will 
provide a field in the LoggerContext?

> Note that if the servlet adds its name to the MDC then all log records will have this
> To be honest though, I would have expected the desire would be to have the ServletContext's
log methods route to Log4j, not the other way around.
The reason is simple.  There is no guarantee that any J2EE container can 
or will allow access to the filesystem.  Using the servlet log-method is 
the _ONLY_ well-defined way to log things inside a J2EE container 
without needing to make assumptions and manual configurations (remember 
the container doesn't help).

Possible assumptions may be:

* I can access the file system.
* Current working directory can be used (for writing or starting navigation)
* The JVM provides environment variable which can be used to locate the 
user.home of the operating system user running the JVM.
* The JVM is allowed to write in user.home.

I like debug logs placed in the filesystem, but I also like to be able 
to send log messages to the standard log mechanism.  The latter I cannot 
do right now.

   Thorbjørn Ravn Andersen  "...plus... Tubular Bells!"

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message