Package org.apache.log4j.spi
Class LoggingEvent
- java.lang.Object
-
- org.apache.log4j.spi.LoggingEvent
-
- Direct Known Subclasses:
LogEventAdapter
public class LoggingEvent extends java.lang.ObjectNo-op version of Log4j 1.2 LoggingEvent. This class is not directly used by Log4j 1.x clients but is used by the Log4j 2 LogEvent adapter to be compatible with Log4j 1.x components.
-
-
Field Summary
Fields Modifier and Type Field Description longtimeStampThe number of milliseconds elapsed from 1/1/1970 until logging event was created.
-
Constructor Summary
Constructors Constructor Description LoggingEvent()Constructs a new instance.LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, long timeStamp, Level level, java.lang.Object message, java.lang.String threadName, ThrowableInformation throwable, java.lang.String ndc, LocationInfo info, java.util.Map properties)Create new instance.LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, java.lang.Object message, java.lang.Throwable throwable)Instantiate a LoggingEvent from the supplied parameters.LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, Priority level, java.lang.Object message, java.lang.Throwable throwable)Instantiate a LoggingEvent from the supplied parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetFQNOfLoggerClass()LevelgetLevel()Return the level of this event.LocationInfogetLocationInformation()Set the location information for this logging event.CategorygetLogger()Gets the logger of the event.java.lang.StringgetLoggerName()Return the name of the logger.java.lang.ObjectgetMDC(java.lang.String key)voidgetMDCCopy()Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.java.lang.ObjectgetMessage()Return the message for this logging event.java.lang.StringgetNDC()java.util.MapgetProperties()java.lang.StringgetProperty(java.lang.String key)java.util.SetgetPropertyKeySet()java.lang.StringgetRenderedMessage()static longgetStartTime()Returns the time when the application started, in milliseconds elapsed since 01.01.1970.java.lang.StringgetThreadName()ThrowableInformationgetThrowableInformation()Returns the throwable information contained within this event.java.lang.String[]getThrowableStrRep()Return this event's throwable's string[] representaion.longgetTimeStamp()java.lang.ObjectremoveProperty(java.lang.String propName)voidsetProperty(java.lang.String propName, java.lang.String propValue)
-
-
-
Constructor Detail
-
LoggingEvent
public LoggingEvent()
Constructs a new instance.
-
LoggingEvent
public LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, long timeStamp, Level level, java.lang.Object message, java.lang.String threadName, ThrowableInformation throwable, java.lang.String ndc, LocationInfo info, java.util.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 eventlevel- The level of this event.message- The message of this event.threadName- thread namethrowable- The throwable of this event.ndc- Nested diagnostic contextinfo- Location infoproperties- MDC properties- Since:
- 1.2.15
-
LoggingEvent
public LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, java.lang.Object message, java.lang.Throwable throwable)Instantiate a LoggingEvent from the supplied parameters.Except
timeStampall the other fields ofLoggingEventare filled when actually needed.- Parameters:
logger- The logger generating this event.timeStamp- the timestamp of this logging eventlevel- The level of this event.message- The message of this event.throwable- The throwable of this event.
-
LoggingEvent
public LoggingEvent(java.lang.String fqnOfCategoryClass, Category logger, Priority level, java.lang.Object message, java.lang.Throwable throwable)Instantiate a LoggingEvent from the supplied parameters.Except
timeStampall the other fields ofLoggingEventare 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.
-
-
Method Detail
-
getStartTime
public static long getStartTime()
Returns the time when the application started, in milliseconds elapsed since 01.01.1970.- Returns:
- the JVM start time.
-
getFQNOfLoggerClass
public java.lang.String getFQNOfLoggerClass()
-
getLevel
public Level getLevel()
Return the level of this event. Use this form instead of directly accessing thelevelfield.- Returns:
- Always returns null.
-
getLocationInformation
public LocationInfo getLocationInformation()
Set the location information for this logging event. The collected information is cached for future use.- Returns:
- Always returns null.
-
getLogger
public Category getLogger()
Gets the logger of the event. Use should be restricted to cloning events.- Returns:
- Always returns null.
- Since:
- 1.2.15
-
getLoggerName
public java.lang.String getLoggerName()
Return the name of the logger. Use this form instead of directly accessing thecategoryNamefield.- Returns:
- Always returns null.
-
getMDC
public java.lang.Object getMDC(java.lang.String key)
-
getMDCCopy
public void getMDCCopy()
Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.
-
getMessage
public java.lang.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.
- Returns:
- Always returns null.
- Since:
- 1.1
-
getNDC
public java.lang.String getNDC()
-
getProperties
public java.util.Map getProperties()
-
getProperty
public java.lang.String getProperty(java.lang.String key)
-
getPropertyKeySet
public java.util.Set getPropertyKeySet()
-
getRenderedMessage
public java.lang.String getRenderedMessage()
-
getThreadName
public java.lang.String getThreadName()
-
getThrowableInformation
public ThrowableInformation getThrowableInformation()
Returns the throwable information contained within this event. May benullif there is no such information.Note that the
Throwableobject contained within aThrowableInformationdoes not survive serialization.- Returns:
- Always returns null.
- Since:
- 1.1
-
getThrowableStrRep
public java.lang.String[] getThrowableStrRep()
Return this event's throwable's string[] representaion.- Returns:
- Always returns null.
-
getTimeStamp
public long getTimeStamp()
-
removeProperty
public java.lang.Object removeProperty(java.lang.String propName)
-
setProperty
public void setProperty(java.lang.String propName, java.lang.String propValue)
-
-