Dec 12, 2011

log4cplus && SysLogAppender

I'm a little experimenting with logging frameworks for C++.
log4cplus is a nice one.

Now I'm doing the first test on OpenIndiana.

The ConfigureAndWatchThread does it's job.
When the app runs and afterwards the config file is copied into the
target directory, the logging starts.

But now I've configured the SysLogAppender:


log4cplus.appender.syslog=log4cplus::SysLogAppender
log4cplus.appender.syslog.ident=WARN
log4cplus.appender.syslog.facility=local0
log4cplus.appender.syslog.layout=log4cplus::PatternLayout
log4cplus.appender.syslog.layout.ConversionPattern=[%d{%d %m %Y %H:%M:%S}] [%t] %-5p %c{2} %%%x%% - %m [%l]%n

And when running the app with the corresponding setting publishes
the message into the configured syslog file:


Dec 12 16:37:44 solewer WARN: [ID 702911 local0.crit] [12 12 2011 15:37:44] [1] FATAL root %% - start of app  [src/main.cpp:36]
Dec 12 16:37:46 solewer WARN: [ID 702911 local0.crit] [12 12 2011 15:37:46] [1] FATAL root %% - finish of app [src/main.cpp:41]

A nice feature to report hard errors to a central logging facility with nearly
no effort.