public class Log4jLogEvent extends Object implements LogEvent
| Modifier and Type | Class and Description |
|---|---|
static class |
Log4jLogEvent.Builder |
| Constructor and Description |
|---|
Log4jLogEvent() |
Log4jLogEvent(long timestamp) |
Log4jLogEvent(String loggerName,
Marker marker,
String loggerFQCN,
Level level,
Message message,
List<Property> properties,
Throwable t)
Constructor.
|
Log4jLogEvent(String loggerName,
Marker marker,
String loggerFQCN,
Level level,
Message message,
Throwable t)
Constructor.
|
Log4jLogEvent(String loggerName,
Marker marker,
String loggerFQCN,
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 boolean |
canDeserialize(Serializable event) |
static Log4jLogEvent |
createEvent(String loggerName,
Marker marker,
String loggerFQCN,
Level level,
Message message,
Throwable thrown,
ThrowableProxy thrownProxy,
Map<String,String> mdc,
ThreadContext.ContextStack ndc,
String threadName,
StackTraceElement location,
long timestamp)
Create a new LogEvent.
|
static Log4jLogEvent |
deserialize(Serializable event) |
boolean |
equals(Object o) |
Map<String,String> |
getContextMap()
Returns the immutable copy of the ThreadContext Map.
|
ThreadContext.ContextStack |
getContextStack()
Returns an immutable copy of the ThreadContext stack.
|
Level |
getLevel()
Returns the logging Level.
|
String |
getLoggerFqcn()
The fully qualified class name of the class that was called by the caller.
|
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.
|
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.
|
long |
getTimeMillis()
Returns the time in milliseconds from the epoch when the event occurred.
|
int |
hashCode() |
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 Log4jLogEvent.Builder |
newBuilder() |
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()
public Log4jLogEvent(long timestamp)
public Log4jLogEvent(String loggerName, Marker marker, String loggerFQCN, Level level, Message message, Throwable t)
loggerName - The name of the Logger.marker - The Marker or null.loggerFQCN - 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 loggerFQCN, Level level, Message message, List<Property> properties, Throwable t)
loggerName - The name of the Logger.marker - The Marker or null.loggerFQCN - 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 loggerFQCN, 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.loggerFQCN - 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.Builder newBuilder()
public static Log4jLogEvent createEvent(String loggerName, Marker marker, String loggerFQCN, Level level, Message message, Throwable thrown, ThrowableProxy thrownProxy, Map<String,String> mdc, ThreadContext.ContextStack ndc, String threadName, StackTraceElement location, long timestamp)
loggerName - The name of the Logger.marker - The Marker or null.loggerFQCN - The fully qualified class name of the caller.level - The logging Level.message - The Message.thrown - A Throwable or null.thrownProxy - 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 LogEventpublic Message getMessage()
getMessage in interface LogEventpublic String getThreadName()
getThreadName in interface LogEventpublic long getTimeMillis()
getTimeMillis in interface LogEventSystem.currentTimeMillis()public Throwable getThrown()
public ThrowableProxy getThrownProxy()
getThrownProxy in interface LogEventpublic Marker getMarker()
public String getLoggerFqcn()
getLoggerFqcn in interface LogEventpublic Map<String,String> getContextMap()
getContextMap in interface LogEventpublic ThreadContext.ContextStack getContextStack()
getContextStack in interface LogEventpublic StackTraceElement getSource()
public static StackTraceElement calcLocation(String fqcnOfLogger)
public boolean isIncludeLocation()
LogEventStackTrace snapshot or not before handing off this event to
another thread.isIncludeLocation in interface LogEventtrue if the source of the logging request is required downstream, false otherwise.LogEvent.getSource()public void setIncludeLocation(boolean includeLocation)
LogEventStackTrace snapshot or not before handing off this event to
another thread.setIncludeLocation in interface LogEventincludeLocation - true if the source of the logging request is required downstream, false
otherwise.LogEvent.getSource()public boolean isEndOfBatch()
LogEventtrue 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 LogEventpublic void setEndOfBatch(boolean endOfBatch)
LogEventimmediateFlush=true configuration.setEndOfBatch in interface LogEventendOfBatch - 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 boolean canDeserialize(Serializable event)
public static Log4jLogEvent deserialize(Serializable event)
Copyright © 1999-2021 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.