logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bender Heri" <HBen...@Ergonomics.ch>
Subject RE: MDC and shared lib
Date Thu, 22 Sep 2005 11:33:25 GMT
Hi

The MDC is kept on a per thread basis. If the webapps log within the same thread they use
the same MDC values.

Within your wrapper you should remove the stored values after the call to the wrapped logger
has taken place:

        MDC.put( "user", aUser );
        try
        {
            ... (call to logger)
        }
        finally
        {
            MDC.remove( "user" );
        }


Heri

> -----Original Message-----
> From: Fabrizio Squittieri [mailto:f.squittieri@comune.prato.it]
> Sent: Thursday, September 22, 2005 10:34 AM
> To: Log4J Users List
> Subject: MDC and shared lib
> 
> 
> Hi there,
> i've got a wrapper which wrap log4j logger, and i put in it some
> information as user and Ip.
>  
> Now we've got a lot of webapps and a shared connection pool which uses
> this log wrapper.
> The wrapper wraps all log calls to log4j and before to do 
> this puts user
> and Ip into the MDC.
>  
> The weird thing is that the shared connection pool puts a USER and IP
> into the wrapper and then log (so USER and IP at the end ara into the
> MDC),
> and sometimes the webapps log their statements with these USER and IP
> instead of their real user and address.
>  
> Is the MDC still valid for a jar which is into the shared/lib 
> of tomcat
> or setting MDC there is an error?
>  
> Thanks
>  
> Fabrizio Squittieri - Programmatore
>  
> Sistema informativo - Comune di Prato
> Via Cairoli 16 - Prato
>  
> Tel. 3338338648
>  
> <mailto:f.squittieri@comune.prato.it> 
> fabrizio@squittieri.it                              
>  
>  
>  
> 

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


Mime
View raw message