Home » apache-log4j-1.2.16 » org.apache » log4j » spi » [javadoc | source]
org.apache.log4j.spi
public class: LoggingEvent [javadoc | source]
java.lang.Object
   org.apache.log4j.spi.LoggingEvent

All Implemented Interfaces:
    Serializable

The internal representation of logging events. When an affirmative decision is made to log then a LoggingEvent instance is created. This instance is passed around to the different log4j components.

This class is of concern to those wishing to extend log4j.

Field Summary
public final transient  String fqnOfCategoryClass    Fully qualified name of the calling category class. 
public final  String categoryName   

The category (logger) name.

     
    public transient  Priority level    Level of logging event. Level cannot be serializable because it is a flyweight. Due to its special seralization it cannot be declared final either.

    This field should not be accessed directly. You shoud use the #getLevel method instead.

       
      public final  long timeStamp    The number of milliseconds elapsed from 1/1/1970 until logging event was created. 
      static final  long serialVersionUID     
      static final  Integer[] PARAM_ARRAY     
      static final  String TO_LEVEL     
      static final  Class[] TO_LEVEL_PARAMS     
      static final  Hashtable methodCache     
      Constructor:
       public LoggingEvent(String fqnOfCategoryClass,
          Category logger,
          Priority level,
          Object message,
          Throwable throwable) 
        Instantiate a LoggingEvent from the supplied parameters.

        Except #timeStamp all the other fields of LoggingEvent are filled when actually needed.

        Parameters:
        logger - The logger generating this event.
        level - The level of this event.
        message - The message of this event.
        throwable - The throwable of this event.
       public LoggingEvent(String fqnOfCategoryClass,
          Category logger,
          long timeStamp,
          Priority level,
          Object message,
          Throwable throwable) 
        Instantiate a LoggingEvent from the supplied parameters.

        Except #timeStamp all the other fields of LoggingEvent are filled when actually needed.

        Parameters:
        logger - The logger generating this event.
        timeStamp - the timestamp of this logging event
        level - The level of this event.
        message - The message of this event.
        throwable - The throwable of this event.
       public LoggingEvent(String fqnOfCategoryClass,
          Category logger,
          long timeStamp,
          Level level,
          Object message,
          String threadName,
          ThrowableInformation throwable,
          String ndc,
          LocationInfo info,
          Map properties) 
        Create new instance.
        Parameters:
        fqnOfCategoryClass - Fully qualified class name of Logger implementation.
        logger - The logger generating this event.
        timeStamp - the timestamp of this logging event
        level - The level of this event.
        message - The message of this event.
        threadName - thread name
        throwable - The throwable of this event.
        ndc - Nested diagnostic context
        info - Location info
        properties - MDC properties
        since: 1.2.15 -
      Method from org.apache.log4j.spi.LoggingEvent Summary:
      getFQNOfLoggerClass,   getLevel,   getLocationInformation,   getLogger,   getLoggerName,   getMDC,   getMDCCopy,   getMessage,   getNDC,   getProperties,   getProperty,   getPropertyKeySet,   getRenderedMessage,   getStartTime,   getThreadName,   getThrowableInformation,   getThrowableStrRep,   getTimeStamp,   locationInformationExists,   removeProperty,   setProperty
      Methods from java.lang.Object:
      clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
      Method from org.apache.log4j.spi.LoggingEvent Detail:
       public String getFQNOfLoggerClass() 
        Get the fully qualified name of the calling logger sub-class/wrapper. Provided for compatibility with log4j 1.3
       public Level getLevel() 
        Return the level of this event. Use this form instead of directly accessing the level field.
       public LocationInfo getLocationInformation() 
        Set the location information for this logging event. The collected information is cached for future use.
       public Category getLogger() 
        Gets the logger of the event. Use should be restricted to cloning events.
       public String getLoggerName() 
        Return the name of the logger. Use this form instead of directly accessing the categoryName field.
       public Object getMDC(String key) 
        Returns the the context corresponding to the key parameter. If there is a local MDC copy, possibly because we are in a logging server or running inside AsyncAppender, then we search for the key in MDC copy, if a value is found it is returned. Otherwise, if the search in MDC copy returns a null result, then the current thread's MDC is used.

        Note that both the local MDC copy and the current thread's MDC are searched.

       public  void getMDCCopy() 
        Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.
       public Object getMessage() 
        Return the message for this logging event.

        Before serialization, the returned object is the message passed by the user to generate the logging event. After serialization, the returned value equals the String form of the message possibly after object rendering.

       public String getNDC() 
        This method returns the NDC for this event. It will return the correct content even if the event was generated in a different thread or even on a different machine. The NDC#get method should never be called directly.
       public Map getProperties() 
        Returns the set of properties for the event. The returned set is unmodifiable by the caller. Provided for compatibility with log4j 1.3
       public final String getProperty(String key) 
        Return a property for this event. The return value can be null. Equivalent to getMDC(String) in log4j 1.2. Provided for compatibility with log4j 1.3.
       public Set getPropertyKeySet() 
        Returns the set of the key values in the properties for the event. The returned set is unmodifiable by the caller. Provided for compatibility with log4j 1.3
       public String getRenderedMessage() 
       public static long getStartTime() 
        Returns the time when the application started, in milliseconds elapsed since 01.01.1970.
       public String getThreadName() 
       public ThrowableInformation getThrowableInformation() 
        Returns the throwable information contained within this event. May be null if there is no such information.

        Note that the Throwable object contained within a ThrowableInformation does not survive serialization.

       public String[] getThrowableStrRep() 
        Return this event's throwable's string[] representaion.
       public final long getTimeStamp() 
        Getter for the event's time stamp. The time stamp is calculated starting from 1970-01-01 GMT.
       public final boolean locationInformationExists() 
        Check for the existence of location information without creating it (a byproduct of calling getLocationInformation).
       public Object removeProperty(String propName) 
        This removes the specified MDC property from the event. Access to the MDC is not synchronized, so this method should only be called when it is known that no other threads are accessing the MDC.
       public final  void setProperty(String propName,
          String propValue) 
        Set value for MDC property. This adds the specified MDC property to the event. Access to the MDC is not synchronized, so this method should only be called when it is known that no other threads are accessing the MDC.