org.apache.logging.log4j.core.impl
Class Log4jLogEvent

java.lang.Object
  extended by org.apache.logging.log4j.core.impl.Log4jLogEvent
All Implemented Interfaces:
Serializable, LogEvent

public class Log4jLogEvent
extends Object
implements LogEvent, Serializable

Implementation of a LogEvent.

See Also:
Serialized Form

Constructor Summary
Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, List<Property> properties, Throwable t)
          Constructor.
Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t)
          Constructor.
Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t, Map<String,String> mdc, ThreadContext.ContextStack ndc, String threadName, StackTraceElement location, long timestamp)
          Constructor.
 
Method Summary
static Log4jLogEvent deserialize(Serializable event)
           
 Map<String,String> getContextMap()
          Returns the immutable copy of the ThreadContext Map.
 ThreadContext.ContextStack getContextStack()
          Returns an immutable copy of the ThreadContext stack.
 String getFQCN()
          The fully qualified class name of the class that was called by the caller.
 Level getLevel()
          Returns the logging Level.
 String getLoggerName()
          Returns the name of the Logger used to generate the event.
 Marker getMarker()
          Returns the Marker associated with the event, or null.
 Message getMessage()
          Returns the Message associated with the event.
 long getMillis()
          Returns the time in milliseconds from the epoch when the event occurred.
 StackTraceElement getSource()
          Returns the StackTraceElement for the caller.
 String getThreadName()
          Returns the name of the Thread on which the event was generated.
 Throwable getThrown()
          Returns the Throwable associated with the event, or null.
static Serializable serialize(Log4jLogEvent event)
           
 String toString()
           
protected  Object writeReplace()
          Creates a LogEventProxy that can be serialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Log4jLogEvent

public Log4jLogEvent(String loggerName,
                     Marker marker,
                     String fqcn,
                     Level level,
                     Message message,
                     Throwable t)
Constructor.

Parameters:
loggerName - The name of the Logger.
marker - The Marker or null.
fqcn - The fully qualified class name of the caller.
level - The logging Level.
message - The Message.
t - A Throwable or null.

Log4jLogEvent

public Log4jLogEvent(String loggerName,
                     Marker marker,
                     String fqcn,
                     Level level,
                     Message message,
                     List<Property> properties,
                     Throwable t)
Constructor.

Parameters:
loggerName - The name of the Logger.
marker - The Marker or null.
fqcn - The fully qualified class name of the caller.
level - The logging Level.
message - The Message.
t - A Throwable or null.

Log4jLogEvent

public Log4jLogEvent(String loggerName,
                     Marker marker,
                     String fqcn,
                     Level level,
                     Message message,
                     Throwable t,
                     Map<String,String> mdc,
                     ThreadContext.ContextStack ndc,
                     String threadName,
                     StackTraceElement location,
                     long timestamp)
Constructor.

Parameters:
loggerName - The name of the Logger.
marker - The Marker or null.
fqcn - The fully qualified class name of the caller.
level - The logging Level.
message - The Message.
t - A Throwable or null.
mdc - The mapped diagnostic context.
ndc - the nested diagnostic context.
threadName - The name of the thread.
location - The locations of the caller.
timestamp - The timestamp of the event.
Method Detail

getLevel

public Level getLevel()
Returns the logging Level.

Specified by:
getLevel in interface LogEvent
Returns:
the Level associated with this event.

getLoggerName

public String getLoggerName()
Returns the name of the Logger used to generate the event.

Specified by:
getLoggerName in interface LogEvent
Returns:
The Logger name.

getMessage

public Message getMessage()
Returns the Message associated with the event.

Specified by:
getMessage in interface LogEvent
Returns:
The Message.

getThreadName

public String getThreadName()
Returns the name of the Thread on which the event was generated.

Specified by:
getThreadName in interface LogEvent
Returns:
The name of the Thread.

getMillis

public long getMillis()
Returns the time in milliseconds from the epoch when the event occurred.

Specified by:
getMillis in interface LogEvent
Returns:
The time the event occurred.

getThrown

public Throwable getThrown()
Returns the Throwable associated with the event, or null.

Specified by:
getThrown in interface LogEvent
Returns:
The Throwable associated with the event.

getMarker

public Marker getMarker()
Returns the Marker associated with the event, or null.

Specified by:
getMarker in interface LogEvent
Returns:
the Marker associated with the event.

getFQCN

public String getFQCN()
The fully qualified class name of the class that was called by the caller.

Specified by:
getFQCN in interface LogEvent
Returns:
the fully qualified class name of the class that is performing logging.

getContextMap

public Map<String,String> getContextMap()
Returns the immutable copy of the ThreadContext Map.

Specified by:
getContextMap in interface LogEvent
Returns:
The context Map.

getContextStack

public ThreadContext.ContextStack getContextStack()
Returns an immutable copy of the ThreadContext stack.

Specified by:
getContextStack in interface LogEvent
Returns:
The context Stack.

getSource

public StackTraceElement getSource()
Returns the StackTraceElement for the caller. This will be the entry that occurs right before the first occurrence of FQCN as a class name.

Specified by:
getSource in interface LogEvent
Returns:
the StackTraceElement for the caller.

writeReplace

protected Object writeReplace()
Creates a LogEventProxy that can be serialized.

Returns:
a LogEventProxy.

serialize

public static Serializable serialize(Log4jLogEvent event)

deserialize

public static Log4jLogEvent deserialize(Serializable event)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.