How to configure Log4cplus Syslog Appender

2k views Asked by At

I want to configure Log4cplus Syslog appender to log messages only under certain conditions, by configuring the Log4cplus config file.

The conditions I want to configure are the followings:

1) use sync/Async sending of log messages to Syslog

2) log only messages that contain a certain string/text (for example to log only messages containing the text: "Fail to connect").

log4cplus.appender.syslog=log4cplus::SysLogAppende
log4cplus.appender.syslog.ident=syslog
log4cplus.appender.syslog.layout=log4cplus::PatternLayout log4cplus.appender.syslog.layout.ConversionPattern=[%T] %-5p %b %x - %m%n
log4cplus.appender.syslog.host=localhost
log4cplus.appender.syslog.udp=true
log4cplus.appender.syslog.port=514
log4cplus.appender.syslog.facility=user

Is there a way to configure these parameters?

1

There are 1 answers

0
wilx On
log4cplus.appender.syslog=log4cplus::SysLogAppende

You are missing r.

log4cplus.appender.syslog.layout=log4cplus::PatternLayout log4cplus.appender.syslog.layout.ConversionPattern=[%T] %-5p %b %x - %m%n

This should be two lines, not one.

log4cplus.appender.syslog.host=localhost
log4cplus.appender.syslog.udp=true
log4cplus.appender.syslog.port=514

You do not need to use UDP to log into local syslog on *NIX OS. If you do still want to log into remote syslog using UDP, do not forget to configure the target syslogd or similar software to actually accept logging messages from UDP. The default is usually to have remote syslog disabled.