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,
org.apache.logging.log4j.Marker marker,
String loggerFQCN,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message message,
List<Property> properties,
Throwable t)
Constructor.
|
Log4jLogEvent(String loggerName,
org.apache.logging.log4j.Marker marker,
String loggerFQCN,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message message,
Throwable t)
Constructor.
|
Log4jLogEvent(String loggerName,
org.apache.logging.log4j.Marker marker,
String loggerFQCN,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message message,
Throwable t,
Map<String,String> mdc,
org.apache.logging.log4j.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,
org.apache.logging.log4j.Marker marker,
String loggerFQCN,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message message,
Throwable thrown,
ThrowableProxy thrownProxy,
Map<String,String> mdc,
org.apache.logging.log4j.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.
|
org.apache.logging.log4j.ThreadContext.ContextStack |
getContextStack()
Returns an immutable copy of the ThreadContext stack.
|
org.apache.logging.log4j.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.
|
org.apache.logging.log4j.Marker |
getMarker()
Returns the Marker associated with the event, or null.
|
org.apache.logging.log4j.message.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, org.apache.logging.log4j.Marker marker, String loggerFQCN, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.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, org.apache.logging.log4j.Marker marker, String loggerFQCN, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.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, org.apache.logging.log4j.Marker marker, String loggerFQCN, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message message, Throwable t, Map<String,String> mdc, org.apache.logging.log4j.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, org.apache.logging.log4j.Marker marker, String loggerFQCN, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message message, Throwable thrown, ThrowableProxy thrownProxy, Map<String,String> mdc, org.apache.logging.log4j.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 org.apache.logging.log4j.Level getLevel()
public String getLoggerName()
getLoggerName
in interface LogEvent
public org.apache.logging.log4j.message.Message getMessage()
getMessage
in interface LogEvent
public String getThreadName()
getThreadName
in interface LogEvent
public long getTimeMillis()
getTimeMillis
in interface LogEvent
System.currentTimeMillis()
public ThrowableProxy getThrownProxy()
getThrownProxy
in interface LogEvent
public org.apache.logging.log4j.Marker getMarker()
public String getLoggerFqcn()
getLoggerFqcn
in interface LogEvent
public Map<String,String> getContextMap()
getContextMap
in interface LogEvent
public org.apache.logging.log4j.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 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.