Apache log4cxx  Version 0.13.0
log4cxx::net::SyslogAppender Class Reference

Use SyslogAppender to send log messages to a remote syslog daemon. More...

#include <syslogappender.h>

Inheritance diagram for log4cxx::net::SyslogAppender:
log4cxx::AppenderSkeleton log4cxx::Appender log4cxx::helpers::Object log4cxx::spi::OptionHandler log4cxx::helpers::Object

Public Member Functions

 SyslogAppender ()
 
 SyslogAppender (const LayoutPtr &layout, int syslogFacility)
 
 SyslogAppender (const LayoutPtr &layout, const LogString &syslogHost, int syslogFacility)
 
 ~SyslogAppender ()
 
void close ()
 Release any resources held by this SyslogAppender. More...
 
void append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)
 Subclasses of AppenderSkeleton should implement this method to perform actual logging. More...
 
void activateOptions (log4cxx::helpers::Pool &p)
 This method returns immediately as options are activated when they are set. More...
 
void setOption (const LogString &option, const LogString &value)
 Set option to value. More...
 
virtual bool requiresLayout () const
 The SyslogAppender requires a layout. More...
 
void setSyslogHost (const LogString &syslogHost)
 The SyslogHost option is the name of the the syslog host where log output should go. More...
 
const LogStringgetSyslogHost () const
 Returns the value of the SyslogHost option. More...
 
void setFacility (const LogString &facilityName)
 Set the syslog facility. More...
 
LogString getFacility () const
 Returns the value of the Facility option. More...
 
void setFacilityPrinting (bool facilityPrinting1)
 If the FacilityPrinting option is set to true, the printed message will include the facility name of the application. More...
 
bool getFacilityPrinting () const
 Returns the value of the FacilityPrinting option. More...
 
void setMaxMessageLength (int maxMessageLength1)
 
int getMaxMessageLength () const
 
- Public Member Functions inherited from log4cxx::AppenderSkeleton
 AppenderSkeleton ()
 
 AppenderSkeleton (const LayoutPtr &layout)
 
void finalize ()
 Finalize this appender by calling the derived class' close method. More...
 
void addFilter (const spi::FilterPtr &newFilter)
 Add a filter to end of the filter list. More...
 
void clearFilters ()
 Clear the filters chain. More...
 
const spi::ErrorHandlerPtrgetErrorHandler () const
 Return the currently set spi::ErrorHandler for this Appender. More...
 
spi::FilterPtr getFilter () const
 Returns the head Filter. More...
 
const spi::FilterPtrgetFirstFilter () const
 Return the first filter in the filter chain for this Appender. More...
 
LayoutPtr getLayout () const
 Returns the layout of this appender. More...
 
LogString getName () const
 Returns the name of this Appender. More...
 
const LevelPtrgetThreshold () const
 Returns this appenders threshold level. More...
 
bool isAsSevereAsThreshold (const LevelPtr &level) const
 Check whether the message level is below the appender's threshold. More...
 
virtual void doAppend (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
 This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method. More...
 
void setErrorHandler (const spi::ErrorHandlerPtr eh)
 Set the ErrorHandler for this Appender. More...
 
void setLayout (const LayoutPtr &layout1)
 Set the layout for this appender. More...
 
void setName (const LogString &name1)
 Set the name of this Appender. More...
 
void setThreshold (const LevelPtr &threshold)
 Set the threshold level. More...
 
- Public Member Functions inherited from log4cxx::Appender
virtual ~Appender ()
 
void asdf ()
 
- Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
 
- 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 LogString getFacilityString (int syslogFacility)
 Returns the specified syslog facility as a lower-case String, e.g. More...
 
static int getFacility (const LogString &facilityName)
 Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized. More...
 

Protected Member Functions

void initSyslogFacilityStr ()
 
- Protected Member Functions inherited from log4cxx::AppenderSkeleton
void doAppendImpl (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
 

Protected Attributes

int syslogFacility
 
LogString facilityStr
 
bool facilityPrinting
 
helpers::SyslogWritersw
 
LogString syslogHost
 
int syslogHostPort
 
int maxMessageLength
 
- Protected Attributes inherited from log4cxx::AppenderSkeleton
LayoutPtr layout
 The layout variable does not need to be set if the appender implementation has its own layout. More...
 
LogString name
 Appenders are named. More...
 
LevelPtr threshold
 There is no level threshold filtering by default. More...
 
spi::ErrorHandlerPtr errorHandler
 It is assumed and enforced that errorHandler is never null. More...
 
spi::FilterPtr headFilter
 The first filter in the filter chain. More...
 
spi::FilterPtr tailFilter
 The last filter in the filter chain. More...
 
bool closed
 Is this appender closed? More...
 
log4cxx::helpers::Pool pool
 
std::recursive_mutex mutex
 

Detailed Description

Use SyslogAppender to send log messages to a remote syslog daemon.

Note that by default, this appender will split up messages that are more than 1024 bytes long, for compatability with BSD syslog(see RFC 3164). Modern syslog implementations(e.g. syslog-ng) can accept messages much larger, and may have a default of 8k. You may modify the default size of the messages by setting the MaxMessageLength option.

When the message is too large for the current MaxMessageLength, the packet number and total # will be appended to the end of the message like this: (5/10)

Constructor & Destructor Documentation

◆ SyslogAppender() [1/3]

log4cxx::net::SyslogAppender::SyslogAppender ( )

◆ SyslogAppender() [2/3]

log4cxx::net::SyslogAppender::SyslogAppender ( const LayoutPtr layout,
int  syslogFacility 
)

◆ SyslogAppender() [3/3]

log4cxx::net::SyslogAppender::SyslogAppender ( const LayoutPtr layout,
const LogString syslogHost,
int  syslogFacility 
)

◆ ~SyslogAppender()

log4cxx::net::SyslogAppender::~SyslogAppender ( )

Member Function Documentation

◆ activateOptions()

void log4cxx::net::SyslogAppender::activateOptions ( log4cxx::helpers::Pool p)
virtual

This method returns immediately as options are activated when they are set.

Reimplemented from log4cxx::AppenderSkeleton.

◆ append()

void log4cxx::net::SyslogAppender::append ( const spi::LoggingEventPtr event,
log4cxx::helpers::Pool p 
)
virtual

Subclasses of AppenderSkeleton should implement this method to perform actual logging.

See also AppenderSkeleton::doAppend method.

Implements log4cxx::AppenderSkeleton.

◆ close()

void log4cxx::net::SyslogAppender::close ( )
virtual

Release any resources held by this SyslogAppender.

Implements log4cxx::Appender.

◆ getFacility() [1/2]

static int log4cxx::net::SyslogAppender::getFacility ( const LogString facilityName)
static

Returns the integer value corresponding to the named syslog facility, or -1 if it couldn't be recognized.

Parameters
facilityNameone of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. The matching is case-insensitive.

◆ getFacility() [2/2]

LogString log4cxx::net::SyslogAppender::getFacility ( ) const
inline

Returns the value of the Facility option.

◆ getFacilityPrinting()

bool log4cxx::net::SyslogAppender::getFacilityPrinting ( ) const
inline

Returns the value of the FacilityPrinting option.

◆ getFacilityString()

static LogString log4cxx::net::SyslogAppender::getFacilityString ( int  syslogFacility)
static

Returns the specified syslog facility as a lower-case String, e.g.

"kern", "user", etc.

◆ getMaxMessageLength()

int log4cxx::net::SyslogAppender::getMaxMessageLength ( ) const
inline

◆ getSyslogHost()

const LogString& log4cxx::net::SyslogAppender::getSyslogHost ( ) const
inline

Returns the value of the SyslogHost option.

◆ initSyslogFacilityStr()

void log4cxx::net::SyslogAppender::initSyslogFacilityStr ( )
protected

◆ requiresLayout()

virtual bool log4cxx::net::SyslogAppender::requiresLayout ( ) const
inlinevirtual

The SyslogAppender requires a layout.

Hence, this method returns true.

Implements log4cxx::Appender.

◆ setFacility()

void log4cxx::net::SyslogAppender::setFacility ( const LogString facilityName)

Set the syslog facility.

This is the Facility option.

The facilityName parameter must be one of the strings KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7. Case is unimportant.

◆ setFacilityPrinting()

void log4cxx::net::SyslogAppender::setFacilityPrinting ( bool  facilityPrinting1)
inline

If the FacilityPrinting option is set to true, the printed message will include the facility name of the application.

It is false by default.

◆ setMaxMessageLength()

void log4cxx::net::SyslogAppender::setMaxMessageLength ( int  maxMessageLength1)
inline

◆ setOption()

void log4cxx::net::SyslogAppender::setOption ( const LogString option,
const LogString value 
)
virtual

Set option to value.

The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when activateOptions is called.

Reimplemented from log4cxx::AppenderSkeleton.

◆ setSyslogHost()

void log4cxx::net::SyslogAppender::setSyslogHost ( const LogString syslogHost)

The SyslogHost option is the name of the the syslog host where log output should go.

WARNING If the SyslogHost is not set, then this appender will fail.

Member Data Documentation

◆ facilityPrinting

bool log4cxx::net::SyslogAppender::facilityPrinting
protected

◆ facilityStr

LogString log4cxx::net::SyslogAppender::facilityStr
protected

◆ maxMessageLength

int log4cxx::net::SyslogAppender::maxMessageLength
protected

◆ sw

helpers::SyslogWriter* log4cxx::net::SyslogAppender::sw
protected

◆ syslogFacility

int log4cxx::net::SyslogAppender::syslogFacility
protected

◆ syslogHost

LogString log4cxx::net::SyslogAppender::syslogHost
protected

◆ syslogHostPort

int log4cxx::net::SyslogAppender::syslogHostPort
protected

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