Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core
Interface LogEvent

All Superinterfaces:
  Serializable

All Known Implementing Classes:
  AbstractLogEvent, AbstractLogEventWrapperEntity, BasicLogEventEntity, Log4jLogEvent, RingBufferLogEvent

    public interface LogEvent

extends Serializable

Provides contextual information about a logged message. A LogEvent must be `Serializable` so that it may be transmitted over a network connection, output in a `SerializedLayout`, and many other uses. Besides containing a `Message`, a LogEvent has a corresponding `Level` that the message was logged at. If a `Marker` was used, then it is included here. The contents of the `ThreadContext` at the time of the log call are provided via `getContextMap()` and `getContextStack()`. If a `Throwable` was included in the log call, then it is provided via `getThrown()`. When this class is serialized, the attached Throwable will be wrapped into a `ThrowableProxy` so that it may be safely serialized and deserialized properly without causing problems if the exception class is not available on the other end.

Method Summary
`Map<String,String>` | `getContextMap()` Gets the context map (also know as Mapped Diagnostic Context or MDC).
`org.apache.logging.log4j.ThreadContext.ContextStack` | `getContextStack()` Gets the context stack (also known as Nested Diagnostic Context or NDC).
`org.apache.logging.log4j.Level` | `getLevel()` Gets the level.
`String` | `getLoggerFqcn()` Returns the fully qualified class name of the caller of the logging API.
`String` | `getLoggerName()` Gets the logger name.
`org.apache.logging.log4j.Marker` | `getMarker()` Gets the Marker associated with the event.
`org.apache.logging.log4j.message.Message` | `getMessage()` Gets the message associated with the event.
`StackTraceElement` | `getSource()` Gets the source of logging request.
`String` | `getThreadName()` Gets thread name.
`Throwable` | `getThrown()` Gets throwable associated with logging request.
`ThrowableProxy` | `getThrownProxy()` Gets throwable proxy associated with logging request.
`long` | `getTimeMillis()` Gets event time in milliseconds since midnight, January 1, 1970 UTC.
`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.
`void` | `setEndOfBatch(boolean endOfBatch)` Sets whether this event is the last one in a batch.
`void` | `setIncludeLocation(boolean locationRequired)` Sets whether the source of the logging request is required downstream.

Method Detail

### getContextMap

    Map<String,String> getContextMap()

  Gets the context map (also know as Mapped Diagnostic Context or MDC).

  Returns:
    The context map, never `null`.

### getContextStack

    org.apache.logging.log4j.ThreadContext.ContextStack getContextStack()

  Gets the context stack (also known as Nested Diagnostic Context or NDC).

  Returns:
    The context stack, never `null`.

### getLoggerFqcn

    String getLoggerFqcn()

  Returns the fully qualified class name of the caller of the logging API.

  Returns:
    The fully qualified class name of the caller.

### getLevel

    org.apache.logging.log4j.Level getLevel()

  Gets the level.

  Returns:
    level.

### getLoggerName

    String getLoggerName()

  Gets the logger name.

  Returns:
    logger name, may be `null`.

### getMarker

    org.apache.logging.log4j.Marker getMarker()

  Gets the Marker associated with the event.

  Returns:
    Marker or `null` if no Marker was defined on this LogEvent

### getMessage

    org.apache.logging.log4j.message.Message getMessage()

  Gets the message associated with the event.

  Returns:
    message.

### getTimeMillis

    long getTimeMillis()

  Gets event time in milliseconds since midnight, January 1, 1970 UTC.

  Returns:
    milliseconds since midnight, January 1, 1970 UTC.
  See Also:
    `System.currentTimeMillis()`

### getSource

    StackTraceElement getSource()

  Gets the source of logging request.

  Returns:
    source of logging request, may be null.

### getThreadName

    String getThreadName()

  Gets thread name.

  Returns:
    thread name, may be null. TODO guess this could go into a thread context object too. (RG) Why?

### getThrown

    Throwable getThrown()

  Gets throwable associated with logging request.

  Convenience method for `ThrowableProxy.getThrowable();`

  Returns:
    throwable, may be null.

### getThrownProxy

    ThrowableProxy getThrownProxy()

  Gets throwable proxy associated with logging request.

  Returns:
    throwable, may be null.

### isEndOfBatch

    boolean isEndOfBatch()

  Returns `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.

  Returns:
    whether this event is the last one in a batch.

### isIncludeLocation

    boolean isIncludeLocation()

  Returns whether the source of the logging request is required downstream. Asynchronous Loggers and Appenders use this flag to determine whether to take a `StackTrace` snapshot or not before handing off this event to another thread.

  Returns:
    `true` if the source of the logging request is required downstream, `false` otherwise.
  See Also:
    `getSource()`

### setEndOfBatch

    void setEndOfBatch(boolean endOfBatch)

  Sets whether this event is the last one in a batch. 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.

  Parameters:
    `endOfBatch` - `true` if this event is the last one in a batch, `false` otherwise.

### setIncludeLocation

    void setIncludeLocation(boolean locationRequired)

  Sets whether the source of the logging request is required downstream. Asynchronous Loggers and Appenders use this flag to determine whether to take a `StackTrace` snapshot or not before handing off this event to another thread.

  Parameters:
    `locationRequired` - `true` if the source of the logging request is required downstream, `false` otherwise.
  See Also:
    `getSource()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 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.