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

This layout outputs events in a JSON dictionary. More...

#include <jsonlayout.h>

Inheritance diagram for log4cxx::JSONLayout:
log4cxx::Layout log4cxx::spi::OptionHandler log4cxx::helpers::Object log4cxx::helpers::Object

Public Member Functions

 JSONLayout ()
 
 ~JSONLayout ()
 
void setLocationInfo (bool locationInfoFlag)
 The LocationInfo option takes a boolean value.
 
bool getLocationInfo () const
 Returns the current value of the LocationInfo option.
 
void setPrettyPrint (bool prettyPrintFlag)
 The PrettyPrint option takes a boolean value.
 
bool getPrettyPrint () const
 Returns the current value of the PrettyPrint option.
 
void setThreadInfo (bool newValue)
 Set thread info output mode to newValue.
 
bool getThreadInfo () const
 Is a thread identifier included in the output?
 
LogString getContentType () const override
 Returns the content type output by this layout, i.e "application/json".
 
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 &pool) const override
 Implement this method to create your own layout format.
 
bool ignoresThrowable () const override
 The JSON layout handles the throwable contained in logging events.
 
- 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
 

Static Public Member Functions

static void appendItem (const LogString &item, LogString &toAppendTo)
 

Protected Member Functions

void appendQuotedEscapedString (LogString &buf, const LogString &input) const
 
void appendSerializedMDC (LogString &buf, const spi::LoggingEventPtr &event) const
 
void appendSerializedNDC (LogString &buf, const spi::LoggingEventPtr &event) const
 
void appendSerializedLocationInfo (LogString &buf, const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p) const
 
- Protected Member Functions inherited from log4cxx::Layout
size_t getFormattedEventCharacterCount () const
 The expected length of a formatted event excluding the message text.
 

Detailed Description

This layout outputs events in a JSON dictionary.

Constructor & Destructor Documentation

◆ JSONLayout()

log4cxx::JSONLayout::JSONLayout ( )

◆ ~JSONLayout()

log4cxx::JSONLayout::~JSONLayout ( )

Member Function Documentation

◆ activateOptions()

void log4cxx::JSONLayout::activateOptions ( helpers::Pool )
overridevirtual

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

No action is performed in this implementation.

Implements log4cxx::spi::OptionHandler.

◆ appendItem()

static void log4cxx::JSONLayout::appendItem ( const LogString item,
LogString toAppendTo 
)
static

◆ appendQuotedEscapedString()

void log4cxx::JSONLayout::appendQuotedEscapedString ( LogString buf,
const LogString input 
) const
protected

◆ appendSerializedLocationInfo()

void log4cxx::JSONLayout::appendSerializedLocationInfo ( LogString buf,
const spi::LoggingEventPtr event,
log4cxx::helpers::Pool p 
) const
protected

◆ appendSerializedMDC()

void log4cxx::JSONLayout::appendSerializedMDC ( LogString buf,
const spi::LoggingEventPtr event 
) const
protected

◆ appendSerializedNDC()

void log4cxx::JSONLayout::appendSerializedNDC ( LogString buf,
const spi::LoggingEventPtr event 
) const
protected

◆ format()

void log4cxx::JSONLayout::format ( LogString output,
const spi::LoggingEventPtr event,
helpers::Pool pool 
) const
overridevirtual

Implement this method to create your own layout format.

Implements log4cxx::Layout.

◆ getContentType()

LogString log4cxx::JSONLayout::getContentType ( ) const
overridevirtual

Returns the content type output by this layout, i.e "application/json".

Reimplemented from log4cxx::Layout.

◆ getLocationInfo()

bool log4cxx::JSONLayout::getLocationInfo ( ) const

Returns the current value of the LocationInfo option.

◆ getPrettyPrint()

bool log4cxx::JSONLayout::getPrettyPrint ( ) const

Returns the current value of the PrettyPrint option.

◆ getThreadInfo()

bool log4cxx::JSONLayout::getThreadInfo ( ) const

Is a thread identifier included in the output?

◆ ignoresThrowable()

bool log4cxx::JSONLayout::ignoresThrowable ( ) const
inlineoverridevirtual

The JSON layout handles the throwable contained in logging events.

Hence, this method return false.

Implements log4cxx::Layout.

◆ setLocationInfo()

void log4cxx::JSONLayout::setLocationInfo ( bool  locationInfoFlag)

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.

◆ setOption()

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

Set option to value.

Supported options Supported values Default value
LocationInfo True,False false
ThreadInfo True,False false
PrettyPrint True,False false

Implements log4cxx::spi::OptionHandler.

◆ setPrettyPrint()

void log4cxx::JSONLayout::setPrettyPrint ( bool  prettyPrintFlag)

The PrettyPrint option takes a boolean value.

By default, it is set to false which means output by this layout will be one line per log event. If the option is set to true, then then each log event will produce multiple lines, each indented for readability.

◆ setThreadInfo()

void log4cxx::JSONLayout::setThreadInfo ( bool  newValue)

Set thread info output mode to newValue.

Parameters
newValuetrue to include a thread identifier.

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