log4rs-syslog
log4rs-syslog
- very simple syslog appender for the log4rs based on the libc's syslog() function. Supports only *nix
systems.
Features:
- Logging with or without calling openlog() with identification string, logging options and facility.
- Custom mapping between rust's
log
crate log levels and syslog's log levels.
Limitations:
- When there are multiple syslog appenders, openlog() configuration of last built appender is used.
- openlog() configuration applied when log4rs_syslog::SyslogAppenderBuilder::build() called, not on log4rs::init_config() or log4rs::Handle::set_config().
There is no proper way to fix this limitations while using libc's interface.
Breaking changes
2.0 → 3.0
- Update to
log
0.4 andlog4rs
0.8.
1.0 → 2.0
log4rs_syslog::register_deserializer()
renamed tolog4rs_syslog::register()
.kind
in deserializable configuration file changed fromsyslog
tolibc-syslog
.- Log option constants changed from
log4rs_syslog::LOG_*
tolog4rs_syslog::LogOption::LOG_*
due to changes inbitflags
crate.
Usage
Add this to your Cargo.toml:
[]
= "3.0"
Initialization based on configuration file
Example configuration file:
appenders:
syslog:
kind: libc-syslog
openlog:
ident: log4rs-syslog-example
option: LOG_PID | LOG_NDELAY | LOG_CONS
facility: Daemon
encoder:
pattern: "{M} - {m}"
root:
level: trace
appenders:
- syslog
Example code:
extern crate log;
extern crate log4rs;
extern crate log4rs_syslog;
Manual initialization
Example code:
extern crate log;
extern crate log4rs;
extern crate log4rs_syslog;
Running examples