org.oddjob.logging
Class OddjobNDC

java.lang.Object
  extended by org.oddjob.logging.OddjobNDC
All Implemented Interfaces:
LoggingConstants

public class OddjobNDC
extends Object
implements LoggingConstants

An OddjobNDC is a Nested Diagnostic Context for Oddjob. It provides a way of allowing component by component logging.

It is very crude wrapper for the Log4j MDC class. One day it would be nice to work out how to apply this to other logging utilities.

Note that this is a thread based nested diagnostic context that does not interfere with Log4j's own. It populates log4j's mapped diagnostic context instead.

Author:
rob

Nested Class Summary
static class OddjobNDC.LoggerAndJob
          Holds Logger and Job information for the Stack.
 
Field Summary
 
Fields inherited from interface org.oddjob.logging.LoggingConstants
MDC_JOB_NAME, MDC_LOGGER
 
Method Summary
static OddjobNDC.LoggerAndJob peek()
          Looks at the last diagnostic context at the top of this NDC without removing it.
static OddjobNDC.LoggerAndJob pop()
          Clients should call this method before leaving a diagnostic context.
static void push(String loggerName, Object job)
          Push new diagnostic context information for the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pop

public static OddjobNDC.LoggerAndJob pop()
Clients should call this method before leaving a diagnostic context.

The returned value is the value that was pushed last. If no context is available, then the empty string "" is returned.

Returns:
LoggerAndJob The innermost diagnostic context.

peek

public static OddjobNDC.LoggerAndJob peek()
Looks at the last diagnostic context at the top of this NDC without removing it.

The returned value is the value that was pushed last. If no context is available, then the empty string "" is returned.

Returns:
LoggerAndJob The innermost diagnostic context.

push

public static void push(String loggerName,
                        Object job)
Push new diagnostic context information for the current thread.

Parameters:
loggerName - The new diagnostic context information.