On Jul 16, 2008, at 8:29 AM, Duseja, Sushil wrote:

Hello,

I used event.getNDC() to log the NDC value (where event is a
org.apache.log4j.spi.LoggingEvent object), but it's fetching - 'null'.
Similarly, I used event.getThrowableStrRep() to log the exception value
but that is again fetching a null.

event.getNDC() would be expected to be null if no NDC value had been set for the thread. event.getThrowableStrRep() would be expected to be null if you did not call one of the logging methods that took an exception as the second argument. Since we don't have access to your test app and you haven't described it, there is nothing to indicate that anything is wrong.

If you want to set the NDC value, do something like:

NDC.push("Context 1");
logger.debug("Hello, World");
NDC.pop();

If you want to a logging request to include an exception:

try {
...
} catch(Exception e) {
        logger.warn("Unable to complete action", e);
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to