Fafnix.org About | Privacy Policy

fsyslogd

The formatting syslog daemon fsyslogd is a very lightweight system log daemon. The output format of the log messages can be completely customized with a user specified format string.

fsyslogd can access the following logging sources:

fsyslogd is expected to be run under a supervision framework like runit or daemontools. It does not write to any file by itself, but writes all log messages to stdout. The supervision framework or specifically its logger is responsible for the actual writing to a log file and the log file rotation.

The small codebase (~1k LoC) has no dependencies. It is designed in a way that it must never crash, for example there is no dynamic memory allocation at all. If you nevertheless experience any bugs, please write to leclaire@fafnix.org.

Download

Release directory

License: GPL-3.0-only

Setup

This example setup uses the supervision framework runit. With other supervision frameworks like daemontools the setup should be very similar.

A simple ./run script could look like this.

./run
#!/bin/bash
[ -r conf ] && . ./conf
exec fsyslogd -U fsyslogd -k -u ${FORMAT:+-f "${FORMAT}"}

It starts fsyslogd to run as user fsyslogd. It also allows the format to be specified in a configuration file.

./conf
FORMAT="%[%F_%T.%U_%z]V %e %K %U %A%Y %F.%S: %m"

The actual log writing to file can be created as follows.

./log/run
#!/bin/bash
mkdir /var/log/fsyslogd
for i in $(ls -1 config)
do
        mkdir -m 0770 "/var/log/fsyslogd/${i}"
        chown root:fsyslogd "/var/log/fsyslogd/${i}"
        cp "config/${i}" "/var/log/fsyslogd/${i}/config"
done
exec chpst -u fsyslogd svlogd /var/log/fsyslogd/*

For each log configuration file ./log/config/NAME a corresponding log directory in /var/log/fsyslogd/NAME is created and the logging is done according to the configuration in ./log/config/NAME. For example, if all log messages should be logged to a single log file, it is sufficient to just place an empty file into ./log/config as e.g. ./log/config/everything. For more advanced configuration and log filtering options see svlogd(8).