You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ma...@alltelmd.com on 2002/04/01 19:05:32 UTC

Distributed Logging/MDC Usage Question

I am using JMS (using a modified JMSAppender) to do some distributed
logging (log from different servlets (resin) to a message-driven bean on a
weblogic box). I am passing the loggingEvent object to the message-driven
bean in order to have access to the stack trace, timestamp, etc. I am also
trying to use the MDC to capture the originating ip address (and other
fields) from the application that's doing the logging.  I used the ndc and
was able to use it to transmit additional info just fine. However, when I
use the MDC, I keep receiving nulls on the back-end. I am using the MDC
because it seems like the appropriate place to store multiple name-value
pairs of additional information associated with a loggingEvent. Is there a
better place to store it? If not,  can anyone pick out what I'm doing
incorrectly to deserialize the MDC? See code below:

My Logging Client:
MDC.put("IP Address", "1.1.1.2");
logger.debug ("Testing");


My Message-driven bean reading the logging event:
 Object o = ((ObjectMessage) msg).getObject();
 logEvent  = (LoggingEvent)o;

//print the logging message
 System.out.println ("message:" + logEvent.getMessage());

 logEvent.getMDCCopy();
 String ip = (String)MDC.get("IP Address");

//print the ip address from the MDC
 System.out.println ("IP From MDC:" + ip);

The result when I run the above is:
message:Testing
IP From MDC:null


Regards,
Manish



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>