Apache log4cxx: LoggingEvent Class Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# LoggingEvent Class Reference

Inherits ObjectImpl.

List of all members.

## Detailed Description

The internal representation of logging events.

When an affirmative decision is made to log then a `LoggingEvent` instance is created. This instance is passed around to the different log4cxx components.

This class is of concern to those wishing to extend log4cxx.

## Public Member Functions
| LoggingEvent ()
| For serialization only.
| LoggingEvent (const LogString &logger, const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location)
| Instantiate a LoggingEvent from the supplied parameters.
| ~LoggingEvent ()
const LevelPtr & | getLevel () const
| Return the level of this event.
const LogString & | getLoggerName () const
| Return the name of the logger.
const LogString & | getMessage () const
| Return the message for this logging event.
const LogString & | getRenderedMessage () const
| Return the message for this logging event.
const LogString & | getThreadName () const
| Return the threadName of this event.
log4cxx_time_t | getTimeStamp () const
| Return the timeStamp of this event.
const log4cxx::spi::LocationInfo & | getLocationInformation () const
bool | getNDC (LogString &dest) const
| This method appends the NDC for this event to passed string.
void | write (helpers::ObjectOutputStream &os, helpers::Pool &p) const
| Writes the content of the LoggingEvent in a format compatible with log4j's serialized form.
bool | getMDC (const LogString &key, LogString &dest) const
| Appends the the context corresponding to the `key` parameter.
| LOG4CXX_LIST_DEF (KeySet, LogString)
KeySet | getMDCKeySet () const
| Returns the set of of the key values in the MDC for the event.
void | getMDCCopy () const
| Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.
bool | getProperty (const LogString &key, LogString &dest) const
| Return a previously set property.
KeySet | getPropertyKeySet () const
| Returns the set of of the key values in the properties for the event.
void | setProperty (const LogString &key, const LogString &value)
| Set a string property using a key and a string value.
## Static Public Member Functions
static log4cxx_time_t | getStartTime ()
| Returns the time when the application started, in seconds elapsed since 01.01.1970.

## Constructor & Destructor Documentation

LoggingEvent | ( |  | ) |

| For serialization only.

LoggingEvent | ( | const LogString & | logger,
|  | const LevelPtr & | level,
|  | const LogString & | message,
|  | const log4cxx::spi::LocationInfo & | location
| ) |

  | Instantiate a LoggingEvent from the supplied parameters. Except timeStamp all the other fields of `LoggingEvent` are filled when actually needed. Parameters:
  | logger | The logger of this event.
  | level | The level of this event.
  | message | The message of this event.
  | location | location of logging request.

~LoggingEvent | ( |  | ) |

## Member Function Documentation

const LevelPtr& getLevel | ( |  | ) | const`[inline]`

| Return the level of this event.

const log4cxx::spi::LocationInfo& getLocationInformation | ( |  | ) | const`[inline]`

const LogString& getLoggerName | ( |  | ) | const`[inline]`

| Return the name of the logger.

bool getMDC | ( | const LogString & | key,
|  | LogString & | dest
| ) | const

  | Appends the the context corresponding to the `key` parameter. If there is a local MDC copy, possibly because we are in a logging server or running inside AsyncAppender, then we search for the key in MDC copy, if a value is found it is returned. Otherwise, if the search in MDC copy returns an empty result, then the current thread's `MDC` is used. Note that both the local MDC copy and the current thread's MDC are searched. Parameters:
  | key | key.
  | dest | string to which value, if any, is appended.
Returns: true if key had a corresponding value.

void getMDCCopy | ( |  | ) | const

| Obtain a copy of this thread's MDC prior to serialization or asynchronous logging.

KeySet getMDCKeySet | ( |  | ) | const

| Returns the set of of the key values in the MDC for the event. The returned set is unmodifiable by the caller. Returns: Set an unmodifiable set of the MDC keys.

const LogString& getMessage | ( |  | ) | const`[inline]`

| Return the message for this logging event.

bool getNDC | ( | LogString & | dest | ) | const

  | This method appends the NDC for this event to passed string. It will return the correct content even if the event was generated in a different thread or even on a different machine. The NDC::get method should never be called directly. Parameters:
  | dest | destination for NDC, unchanged if NDC is not set.
Returns: true if NDC is set.

bool getProperty | ( | const LogString & | key,
|  | LogString & | dest
| ) | const

  | Return a previously set property. Parameters:
  | key | key.
  | dest | string to which value, if any, is appended.
Returns: true if key had a corresponding value.

KeySet getPropertyKeySet | ( |  | ) | const

| Returns the set of of the key values in the properties for the event. The returned set is unmodifiable by the caller. Returns: Set an unmodifiable set of the property keys.

const LogString& getRenderedMessage | ( |  | ) | const`[inline]`

| Return the message for this logging event.

static log4cxx_time_t getStartTime | ( |  | ) | `[static]`

| Returns the time when the application started, in seconds elapsed since 01.01.1970.

const LogString& getThreadName | ( |  | ) | const`[inline]`

| Return the threadName of this event.

log4cxx_time_t getTimeStamp | ( |  | ) | const`[inline]`

| Return the timeStamp of this event.

LOG4CXX_LIST_DEF | ( | KeySet | ,
|  | LogString |
| ) |

void setProperty | ( | const LogString & | key,
|  | const LogString & | value
| ) |

| Set a string property using a key and a string value. since 1.3

void write | ( | helpers::ObjectOutputStream & | os,
|  | helpers::Pool & | p
| ) | const

| Writes the content of the LoggingEvent in a format compatible with log4j's serialized form.

The documentation for this class was generated from the following file:

- loggingevent.h