Apache log4cxx  Version 0.12.0
log4cxx::spi::LoggingEvent Class Reference

The internal representation of logging events. More...

#include <loggingevent.h>

Inheritance diagram for log4cxx::spi::LoggingEvent:
log4cxx::helpers::Object

Public Types

typedef spi::KeySet KeySet
 

Public Member Functions

 LoggingEvent ()
 For serialization only. More...
 
 LoggingEvent (const LogString &logger, const LevelPtr &level, const LogString &message, const log4cxx::spi::LocationInfo &location)
 Instantiate a LoggingEvent from the supplied parameters. More...
 
 ~LoggingEvent ()
 
const LevelPtrgetLevel () const
 Return the level of this event. More...
 
const LogStringgetLoggerName () const
 Return the name of the logger. More...
 
const LogStringgetMessage () const
 Return the message for this logging event. More...
 
const LogStringgetRenderedMessage () const
 Return the message for this logging event. More...
 
const LogStringgetThreadName () const
 Return the threadName of this event. More...
 
log4cxx_time_t getTimeStamp () const
 The number of microseconds elapsed from 01.01.1970 until logging event was created. More...
 
const log4cxx::spi::LocationInfogetLocationInformation () const
 
bool getNDC (LogString &dest) const
 This method appends the NDC for this event to passed string. More...
 
void write (helpers::ObjectOutputStream &os, helpers::Pool &p) const
 Writes the content of the LoggingEvent in a format compatible with log4j's serialized form. More...
 
bool getMDC (const LogString &key, LogString &dest) const
 Appends the the context corresponding to the key parameter. More...
 
KeySet getMDCKeySet () const
 Returns the set of of the key values in the MDC for the event. More...
 
void getMDCCopy () const
 Obtain a copy of this thread's MDC prior to serialization or asynchronous logging. More...
 
bool getProperty (const LogString &key, LogString &dest) const
 Return a previously set property. More...
 
KeySet getPropertyKeySet () const
 Returns the set of of the key values in the properties for the event. More...
 
void setProperty (const LogString &key, const LogString &value)
 Set a string property using a key and a string value. More...
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 

Static Public Member Functions

static log4cxx_time_t getStartTime ()
 Returns the time when the application started, in microseconds elapsed since 01.01.1970. More...
 

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.

Member Typedef Documentation

◆ KeySet

Constructor & Destructor Documentation

◆ LoggingEvent() [1/2]

log4cxx::spi::LoggingEvent::LoggingEvent ( )

For serialization only.

◆ LoggingEvent() [2/2]

log4cxx::spi::LoggingEvent::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
loggerThe logger of this event.
levelThe level of this event.
messageThe message of this event.
locationlocation of logging request.

◆ ~LoggingEvent()

log4cxx::spi::LoggingEvent::~LoggingEvent ( )

Member Function Documentation

◆ getLevel()

const LevelPtr& log4cxx::spi::LoggingEvent::getLevel ( ) const
inline

Return the level of this event.

◆ getLocationInformation()

const log4cxx::spi::LocationInfo& log4cxx::spi::LoggingEvent::getLocationInformation ( ) const
inline

◆ getLoggerName()

const LogString& log4cxx::spi::LoggingEvent::getLoggerName ( ) const
inline

Return the name of the logger.

◆ getMDC()

bool log4cxx::spi::LoggingEvent::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
keykey.
deststring to which value, if any, is appended.
Returns
true if key had a corresponding value.

◆ getMDCCopy()

void log4cxx::spi::LoggingEvent::getMDCCopy ( ) const

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

◆ getMDCKeySet()

KeySet log4cxx::spi::LoggingEvent::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.

◆ getMessage()

const LogString& log4cxx::spi::LoggingEvent::getMessage ( ) const
inline

Return the message for this logging event.

◆ getNDC()

bool log4cxx::spi::LoggingEvent::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
destdestination for NDC, unchanged if NDC is not set.
Returns
true if NDC is set.

◆ getProperty()

bool log4cxx::spi::LoggingEvent::getProperty ( const LogString key,
LogString dest 
) const

Return a previously set property.

Parameters
keykey.
deststring to which value, if any, is appended.
Returns
true if key had a corresponding value.

◆ getPropertyKeySet()

KeySet log4cxx::spi::LoggingEvent::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.

◆ getRenderedMessage()

const LogString& log4cxx::spi::LoggingEvent::getRenderedMessage ( ) const
inline

Return the message for this logging event.

◆ getStartTime()

static log4cxx_time_t log4cxx::spi::LoggingEvent::getStartTime ( )
static

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

◆ getThreadName()

const LogString& log4cxx::spi::LoggingEvent::getThreadName ( ) const
inline

Return the threadName of this event.

◆ getTimeStamp()

log4cxx_time_t log4cxx::spi::LoggingEvent::getTimeStamp ( ) const
inline

The number of microseconds elapsed from 01.01.1970 until logging event was created.

◆ setProperty()

void log4cxx::spi::LoggingEvent::setProperty ( const LogString key,
const LogString value 
)

Set a string property using a key and a string value.

since 1.3

◆ write()

void log4cxx::spi::LoggingEvent::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: