Package org.apache.log4j.bridge
Class LogEventAdapter
- java.lang.Object
-
- org.apache.log4j.spi.LoggingEvent
-
- org.apache.log4j.bridge.LogEventAdapter
-
public class LogEventAdapter extends LoggingEvent
Converts a Log4j 2 LogEvent into the components needed by a Log4j 1.x LoggingEvent. This class requires Log4j 2.
-
-
Field Summary
Fields Modifier and Type Field Description private LogEventeventprivate static longJVM_START_TIME-
Fields inherited from class org.apache.log4j.spi.LoggingEvent
timeStamp
-
-
Constructor Summary
Constructors Constructor Description LogEventAdapter(LogEvent event)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LogEventgetEvent()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()private static longinitStartTime()Returns the result ofManagementFactory.getRuntimeMXBean().getStartTime(), or the current system time if JMX is not available.-
Methods inherited from class org.apache.log4j.spi.LoggingEvent
getFQNOfLoggerClass, removeProperty, setProperty
-
-
-
-
Field Detail
-
JVM_START_TIME
private static final long JVM_START_TIME
-
event
private final LogEvent event
-
-
Constructor Detail
-
LogEventAdapter
public LogEventAdapter(LogEvent event)
-
-
Method Detail
-
getStartTime
public static long getStartTime()
Returns the time when the application started, in milliseconds elapsed since 01.01.1970.- Returns:
- the time when the JVM started.
-
initStartTime
private static long initStartTime()
Returns the result ofManagementFactory.getRuntimeMXBean().getStartTime(), or the current system time if JMX is not available.
-
getEvent
public LogEvent getEvent()
-
getLocationInformation
public LocationInfo getLocationInformation()
Set the location information for this logging event. The collected information is cached for future use.- Overrides:
getLocationInformationin classLoggingEvent- Returns:
- Always returns null.
-
getLevel
public Level getLevel()
Return the level of this event. Use this form instead of directly accessing thelevelfield.- Overrides:
getLevelin classLoggingEvent- Returns:
- Always returns null.
-
getLoggerName
public java.lang.String getLoggerName()
Return the name of the logger. Use this form instead of directly accessing thecategoryNamefield.- Overrides:
getLoggerNamein classLoggingEvent- Returns:
- Always returns null.
-
getTimeStamp
public long getTimeStamp()
- Overrides:
getTimeStampin classLoggingEvent
-
getLogger
public Category getLogger()
Gets the logger of the event.- Overrides:
getLoggerin classLoggingEvent- Returns:
- Always returns null.
-
getMessage
public java.lang.Object getMessage()
Description copied from class:LoggingEventReturn 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.
- Overrides:
getMessagein classLoggingEvent- Returns:
- Always returns null.
-
getNDC
public java.lang.String getNDC()
- Overrides:
getNDCin classLoggingEvent
-
getMDC
public java.lang.Object getMDC(java.lang.String key)
- Overrides:
getMDCin classLoggingEvent
-
getMDCCopy
public void getMDCCopy()
Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.- Overrides:
getMDCCopyin classLoggingEvent
-
getRenderedMessage
public java.lang.String getRenderedMessage()
- Overrides:
getRenderedMessagein classLoggingEvent
-
getThreadName
public java.lang.String getThreadName()
- Overrides:
getThreadNamein classLoggingEvent
-
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.- Overrides:
getThrowableInformationin classLoggingEvent- Returns:
- Always returns null.
- Since:
- 1.1
-
getThrowableStrRep
public java.lang.String[] getThrowableStrRep()
Return this event's throwable's string[] representaion.- Overrides:
getThrowableStrRepin classLoggingEvent- Returns:
- Always returns null.
-
getProperty
public java.lang.String getProperty(java.lang.String key)
- Overrides:
getPropertyin classLoggingEvent
-
getPropertyKeySet
public java.util.Set getPropertyKeySet()
- Overrides:
getPropertyKeySetin classLoggingEvent
-
getProperties
public java.util.Map getProperties()
- Overrides:
getPropertiesin classLoggingEvent
-
-