public class Log4jLogEvent extends Object implements LogEvent
Constructor and Description |
---|
Log4jLogEvent(long timestamp) |
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.
|
Modifier and Type | Method and Description |
---|---|
static StackTraceElement |
calcLocation(String fqcnOfLogger) |
static Log4jLogEvent |
createEvent(String loggerName,
Marker marker,
String fqcn,
Level level,
Message message,
ThrowableProxy t,
Map<String,String> mdc,
ThreadContext.ContextStack ndc,
String threadName,
StackTraceElement location,
long timestamp)
Create a new LogEvent.
|
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.
|
ThrowableProxy |
getThrownProxy()
Returns the ThrowableProxy associated with the event, or null.
|
boolean |
isEndOfBatch()
Returns
true if this event is the last one in a batch,
false otherwise. |
boolean |
isIncludeLocation()
Returns whether the source of the logging request is required downstream.
|
static Serializable |
serialize(Log4jLogEvent event,
boolean includeLocation) |
void |
setEndOfBatch(boolean endOfBatch)
Sets whether this event is the last one in a batch.
|
void |
setIncludeLocation(boolean includeLocation)
Sets whether the source of the logging request is required downstream.
|
String |
toString() |
protected Object |
writeReplace()
Creates a LogEventProxy that can be serialized.
|
public Log4jLogEvent(long timestamp)
public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, Throwable t)
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.public Log4jLogEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, List<Property> properties, Throwable t)
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.properties
- properties to add to the event.t
- A Throwable or null.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)
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.public static Log4jLogEvent createEvent(String loggerName, Marker marker, String fqcn, Level level, Message message, ThrowableProxy t, Map<String,String> mdc, ThreadContext.ContextStack ndc, String threadName, StackTraceElement location, long timestamp)
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 ThrowableProxy 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.public Level getLevel()
public String getLoggerName()
getLoggerName
in interface LogEvent
public Message getMessage()
getMessage
in interface LogEvent
public String getThreadName()
getThreadName
in interface LogEvent
public long getMillis()
public Throwable getThrown()
public ThrowableProxy getThrownProxy()
public Marker getMarker()
public String getFQCN()
public Map<String,String> getContextMap()
getContextMap
in interface LogEvent
public ThreadContext.ContextStack getContextStack()
getContextStack
in interface LogEvent
public StackTraceElement getSource()
public static StackTraceElement calcLocation(String fqcnOfLogger)
public boolean isIncludeLocation()
LogEvent
StackTrace
snapshot or not before handing off this
event to another thread.isIncludeLocation
in interface LogEvent
true
if the source of the logging request is required
downstream, false
otherwise.LogEvent.getSource()
public void setIncludeLocation(boolean includeLocation)
LogEvent
StackTrace
snapshot or not before handing off this
event to another thread.setIncludeLocation
in interface LogEvent
includeLocation
- true
if the source of the logging request
is required downstream, false
otherwise.LogEvent.getSource()
public boolean isEndOfBatch()
LogEvent
true
if this event is the last one in a batch,
false
otherwise. Used by asynchronous Loggers and Appenders to
signal to buffered downstream components when to flush to disk, as a
more efficient alternative to the immediateFlush=true
configuration.isEndOfBatch
in interface LogEvent
public void setEndOfBatch(boolean endOfBatch)
LogEvent
immediateFlush=true
configuration.setEndOfBatch
in interface LogEvent
endOfBatch
- true
if this event is the last one in a batch,
false
otherwise.protected Object writeReplace()
public static Serializable serialize(Log4jLogEvent event, boolean includeLocation)
public static Log4jLogEvent deserialize(Serializable event)
Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.