Why is it what I'm trying to do not working though?  It seems that my 
MyLog.getLogger function does find the correct logger name, and that 
Logger.getLogger() is always using the the first log4j.properties that was 
found.

Yeah, I had tried something like this, namely to have a class AbstractMyLog in 
the common folder, and a class MyLog in each of the webapps that derives from 
AbstractMyLog so as to minimize code changes.  But then the common code also 
needs to write to the log file, and it should use the log file of the web 
application that called it.

The other ideas I had are:

(1) Pass a logger from the webapp to the common code -- ie. to add a Logger 
argument to all the functions in the common code, but this sounds tedious.

(2) In each webapp have a filter that sets a thread local variable like 
ThreadLocal<Logger> threadLogger.


--- On Tue, 1/13/09, Caldarale, Charles R <chuck.caldar...@unisys.com> wrote:

> From: Caldarale, Charles R <chuck.caldar...@unisys.com>
> Subject: RE: How to have multiple loggers with shared code also using the  
> logger?
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Date: Tuesday, January 13, 2009, 6:21 AM
> > From: removeps-gro...@yahoo.com
> [mailto:removeps-gro...@yahoo.com]
> > Subject: How to have multiple loggers with shared code
> also
> > using the logger?
> >
> > How to have multiple loggers with shared code also
> using the logger?
> > In ${catalina.home}/lib there is a jar file that
> contains class MyLog.
> 
> "Doctor, doctor, it hurts when I do this."
> 
> The simple fix is: don't do it.  Package your webapps
> so that each contains a copy of MyLog rather than putting
> that class in the common location.  You can still maintain
> the same source, just make sure the .class file is located
> locally in each webapp that uses it.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR
> OTHERWISE PROPRIETARY MATERIAL and is thus for use only by
> the intended recipient. If you received this in error,
> please contact the sender and delete the e-mail and its
> attachments from all computers.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail:
> users-h...@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to