Apache Log4cxx  Version 1.2.0
Loading...
Searching...
No Matches
log4cxx::xml::XMLLayout Class Reference

The output of the XMLLayout consists of a series of log4j:event elements. More...

#include <xmllayout.h>

Inheritance diagram for log4cxx::xml::XMLLayout:
log4cxx::Layout log4cxx::spi::OptionHandler log4cxx::helpers::Object log4cxx::helpers::Object

Public Member Functions

 XMLLayout ()
 
 ~XMLLayout ()
 
void setLocationInfo (bool locationInfo1)
 The LocationInfo option takes a boolean value.
 
bool getLocationInfo () const
 Returns the current value of the LocationInfo option.
 
void setProperties (bool flag)
 Sets whether MDC key-value pairs should be output, default false.
 
bool getProperties ()
 Gets whether MDC key-value pairs should be output.
 
void activateOptions (helpers::Pool &) override
 Activate the options that were previously set with calls to option setters.
 
void setOption (const LogString &option, const LogString &value) override
 Set option to value.
 
void format (LogString &output, const spi::LoggingEventPtr &event, helpers::Pool &p) const override
 Formats a LoggingEvent in conformance with the log4cxx.dtd.
 
bool ignoresThrowable () const override
 The XMLLayout prints and does not ignore exceptions.
 
- Public Member Functions inherited from log4cxx::Layout
virtual ~Layout ()
 
virtual void format (LogString &output, const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool) const =0
 Implement this method to create your own layout format.
 
virtual LogString getContentType () const
 Returns the content type output by this layout.
 
virtual void appendHeader (LogString &output, log4cxx::helpers::Pool &p)
 Append the header for the layout format.
 
virtual void appendFooter (LogString &output, log4cxx::helpers::Pool &p)
 Append the footer for the layout format.
 
virtual bool ignoresThrowable () const =0
 If the layout handles the throwable object contained within LoggingEvent, then the layout should return false.
 
- Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
 
virtual void activateOptions (helpers::Pool &p)=0
 Activate the options that were previously set with calls to option setters.
 
virtual void setOption (const LogString &option, const LogString &value)=0
 Set option to value.
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual const helpers::ClassgetClass () const =0
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 

Additional Inherited Members

- Protected Member Functions inherited from log4cxx::Layout
size_t getFormattedEventCharacterCount () const
 The expected length of a formatted event excluding the message text.
 

Detailed Description

The output of the XMLLayout consists of a series of log4j:event elements.

It does not output a complete well-formed XML file. The output is designed to be included as an external entity in a separate file to form a correct XML file.

For example, if abc is the name of the file where the XMLLayout ouput goes, then a well-formed XML file would be:

<?xml version="1.0" ?>

<!DOCTYPE log4j:eventSet [<!ENTITY data SYSTEM "abc">]>

<log4j:eventSet version="1.2" xmlns:log4j="http://jakarta.apache.org/log4j/">

    @&data;

</log4j:eventSet>

This approach enforces the independence of the XMLLayout and the appender where it is embedded.

Constructor & Destructor Documentation

◆ XMLLayout()

log4cxx::xml::XMLLayout::XMLLayout ( )

◆ ~XMLLayout()

log4cxx::xml::XMLLayout::~XMLLayout ( )

Member Function Documentation

◆ activateOptions()

void log4cxx::xml::XMLLayout::activateOptions ( helpers::Pool )
inlineoverridevirtual

Activate the options that were previously set with calls to option setters.

No action is performed in this implementation.

Implements log4cxx::spi::OptionHandler.

◆ format()

void log4cxx::xml::XMLLayout::format ( LogString output,
const spi::LoggingEventPtr event,
helpers::Pool p 
) const
overridevirtual

Formats a LoggingEvent in conformance with the log4cxx.dtd.

Implements log4cxx::Layout.

◆ getLocationInfo()

bool log4cxx::xml::XMLLayout::getLocationInfo ( ) const

Returns the current value of the LocationInfo option.

◆ getProperties()

bool log4cxx::xml::XMLLayout::getProperties ( )

Gets whether MDC key-value pairs should be output.

Returns
true if MDC key-value pairs are output.

◆ ignoresThrowable()

bool log4cxx::xml::XMLLayout::ignoresThrowable ( ) const
inlineoverridevirtual

The XMLLayout prints and does not ignore exceptions.

Hence the return value false.

Implements log4cxx::Layout.

◆ setLocationInfo()

void log4cxx::xml::XMLLayout::setLocationInfo ( bool  locationInfo1)

The LocationInfo option takes a boolean value.

By default, it is set to false which means there will be no location information output by this layout. If the the option is set to true, then the file name and line number of the statement at the origin of the log statement will be output.

If you are embedding this layout within a SMTPAppender then make sure to set the LocationInfo option of that appender as well.

◆ setOption()

void log4cxx::xml::XMLLayout::setOption ( const LogString option,
const LogString value 
)
overridevirtual

Set option to value.

Supported options Supported values Default value
Properties True,False False
LocationInfo True,False False

Implements log4cxx::spi::OptionHandler.

◆ setProperties()

void log4cxx::xml::XMLLayout::setProperties ( bool  flag)

Sets whether MDC key-value pairs should be output, default false.

Parameters
flagnew value.

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