Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
log4cxx::ConsoleAppender Class Reference

ConsoleAppender appends log events to stdout or stderr using a layout specified by the user. More...

#include <consoleappender.h>

Inheritance diagram for log4cxx::ConsoleAppender:
log4cxx::WriterAppender log4cxx::AppenderSkeleton log4cxx::Appender log4cxx::spi::OptionHandler log4cxx::helpers::Object

Public Member Functions

 ConsoleAppender ()
 A stdout log event appender.
 ConsoleAppender (const LayoutPtr &layout)
 A stdout log event appender formatted using layout.
 ConsoleAppender (const LayoutPtr &layout, const LogString &target)
 A target log event appender formatted using layout.
 ~ConsoleAppender ()
void setTarget (const LogString &newValue)
 Use newValue for the target property.
LogString getTarget () const
void activateOptions () override
 Derived appenders should override this method if option structure requires it.
void setOption (const LogString &option, const LogString &value) override
 Override this method to set option to value.
Public Member Functions inherited from log4cxx::WriterAppender
 WriterAppender ()
 An uninitialised Appender.
 ~WriterAppender ()
void activateOptions () override
 Derived appenders should override this method if option structure requires it.
void setImmediateFlush (bool value)
 If the ImmediateFlush option is set to true, the appender will flush at the end of each write.
bool getImmediateFlush () const
 Returns value of the ImmediateFlush option.
void append (const spi::LoggingEventPtr &event) override
 This method is called by the AppenderSkeleton::doAppend method.
LogString getEncoding () const
 The current encoding value.
void setEncoding (const LogString &value)
 Set the encoding to value.
void setOption (const LogString &option, const LogString &value) override
 Override this method to set option to value.
void activateOptions (helpers::Pool &)
Public Member Functions inherited from log4cxx::AppenderSkeleton
 AppenderSkeleton (const LayoutPtr &layout={})
virtual ~AppenderSkeleton ()
void addFilter (const spi::FilterPtr &newFilter) override
 Add newFilter to end of the spi::Filter chain.
void clearFilters () override
 Clear the spi::Filter chain.
void close () override
 Release any resources allocated within the appender such as file handles, network connections, etc.
const spi::ErrorHandlerPtr getErrorHandler () const
 The currently set spi::ErrorHandler for this Appender.
spi::FilterPtr getFilter () const override
 The first spi::Filter in the filter chain for this Appender.
const spi::FilterPtr getFirstFilter () const
 The first spi::Filter in the filter chain for this Appender.
LayoutPtr getLayout () const override
 The currently set Layout for this appender.
LogString getName () const override
 The name of this Appender.
const LevelPtr getThreshold () const
 This appender's current threshold level.
bool isAsSevereAsThreshold (const LevelPtr &level) const
 Is level greater than or equal to this appender's threshold?
void doAppend (const spi::LoggingEventPtr &event) override
 Call doAppendImpl after acquiring a lock that prevents other threads from concurrently executing doAppendImpl.
void setErrorHandler (const spi::ErrorHandlerPtr &newValue)
 Use newValue as the spi::ErrorHandler for this Appender.
void setLayout (const LayoutPtr &newValue) override
 Use newValue as the layout for this appender.
void setName (const LogString &newValue) override
 Use newValue for the name of this Appender.
void setThreshold (const LevelPtr &newValue)
 Use newValue as this appender's threshold level.
void activateOptions (helpers::Pool &)
Public Member Functions inherited from log4cxx::Appender
virtual ~Appender ()
void doAppend (const spi::LoggingEventPtr &event, helpers::Pool &pool)
virtual bool requiresLayout () const
Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
void activateOptions (helpers::Pool &)
Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
virtual const helpers::Class & getClass () const =0
virtual bool instanceof (const Class &clazz) const =0
virtual const void * cast (const Class &clazz) const =0

Static Public Member Functions

static const LogString & getSystemOut ()
static const LogString & getSystemErr ()

Additional Inherited Members

Protected Member Functions inherited from log4cxx::WriterAppender
 WriterAppender (const LayoutPtr &layout, const helpers::WriterPtr &writer=helpers::WriterPtr())
 An appender that writes spi::LoggingEvent messages formatted by layout to the character stream attached to writer.
 WriterAppender (std::unique_ptr< WriterAppenderPriv > priv)
 An appender that uses the sub-classed priv instance data.
virtual bool checkEntryConditions () const
 This method determines if there is a sense in attempting to append.
virtual void subAppend (const spi::LoggingEventPtr &event)
 Format event as a message and write it to the character stream.
Protected Member Functions inherited from log4cxx::AppenderSkeleton
 AppenderSkeleton (LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv)
void doAppendImpl (const spi::LoggingEventPtr &event)
 Call the AppenderSkeleton::append method if the level of event is not lower than this appender's threshold and no attached spi::Filter indicates event is rejected.
bool isAccepted (const spi::LoggingEventPtr &event) const
 Does no attached filter deny event or does an attached filter accept event?

Detailed Description

ConsoleAppender appends log events to stdout or stderr using a layout specified by the user.

The default target is stdout.

You can use fwide(stdout, 1) in your configuration code or use the cmake directive LOG4CXX_FORCE_WIDE_CONSOLE=ON when building Log4cxx to force Log4cxx to use fputws. If doing this ensure the cmake directive LOG4CXX_WCHAR_T is also enabled.

Constructor & Destructor Documentation

◆ ConsoleAppender() [1/3]

log4cxx::ConsoleAppender::ConsoleAppender ( )

A stdout log event appender.

See also setLayout and setTarget.

◆ ConsoleAppender() [2/3]

log4cxx::ConsoleAppender::ConsoleAppender ( const LayoutPtr & layout)

A stdout log event appender formatted using layout.

Parameters
layoutformats a log event

◆ ConsoleAppender() [3/3]

log4cxx::ConsoleAppender::ConsoleAppender ( const LayoutPtr & layout,
const LogString & target )

A target log event appender formatted using layout.

Parameters
layoutformats a log event
targetthe value provided by getSystemOut or getSystemErr

◆ ~ConsoleAppender()

log4cxx::ConsoleAppender::~ConsoleAppender ( )

Member Function Documentation

◆ activateOptions()

void log4cxx::ConsoleAppender::activateOptions ( )
overridevirtual

Derived appenders should override this method if option structure requires it.

No action is performed in this implementation.

Reimplemented from log4cxx::AppenderSkeleton.

◆ getSystemErr()

const LogString & log4cxx::ConsoleAppender::getSystemErr ( )
static
Returns
the name recognised as stderr.

◆ getSystemOut()

const LogString & log4cxx::ConsoleAppender::getSystemOut ( )
static
Returns
the name recognised as stdout.

◆ getTarget()

LogString log4cxx::ConsoleAppender::getTarget ( ) const
Returns
the current value of the target property.

◆ setOption()

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

Override this method to set option to value.

Supported options Supported values Default value
Target System.err,System.out System.out
See also
WriterAppender::setOption()

Reimplemented from log4cxx::AppenderSkeleton.

◆ setTarget()

void log4cxx::ConsoleAppender::setTarget ( const LogString & newValue)

Use newValue for the target property.

Parameters
newValuethe value provided by getSystemOut or getSystemErr

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