SYSLOGD(8)

NAME
syslogd - log systems messages

SYNOPSIS
syslogd [-?468AcdFHKklnsTtv] [-a addr[/len][:port]] [-a name[:port]] [-b addr[:port][%iface]] [-b :port] [-C file] [-f file] [-m interval] [-M size] [-P file] [-p sock] [-r size[:count]]

DESCRIPTION
The syslogd utility reads and logs messages to the system console, log files, other machines and/or users as specified by its configuration file.

syslogd support RFC3164 and RFC5424 style log messages for both local and remote logging using Internet and UNIX domain sockets. Differences in style is shown below.

RFC3164:
    Aug 24 05:14:15 192.0.2.1 myproc[8710]: Kilroy was here.
RFC5424:
    2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - Kilroy was here.

Note, for remote logging the messages are prefixed with ‘<PRI>’ or ‘<PRI>1’, respectively.

syslogd is derived from BSD sources, today FreeBSD is the reference for syslogd and NetBSD for the new syslogp(3) API, which fully supports the new features of RFC5424. Please note; 1) the intention is to follow standard BSD syslogd behavior, 2) despite having a stand-alone syslog(3), and syslogp(3) API in libsyslog, syslogd interacts transparently with the standard C library syslog(3) API, as implemented in GLIBC, musl libc, and uClibc.

When syslogd starts up it reads its main configuration file /etc/syslog.conf, or an alternate file given with the -f file option. For details on how to set up syslog message filtering, using priority (facility.severity) program or host name, or message property filtering, see syslog.conf(5).

OPTIONS
By default, syslogd reads messages from the UNIX domain socket /dev/log, from an Internet domain socket specified in /etc/services, and from /dev/kmsg (to read kernel messages). The command line options defined below can be used to change this behavior.

The options are as follows:

-4  Force syslogd to use IPv4 addresses only.

-6  Force syslogd to use IPv6 addresses only.

-8  Tells syslogd not to interfere with 8-bit data. Normally syslogd replaces C1 control characters (ISO 8859 and Unicode characters) with their “M-x” equivalent. Note, this option does not change the way syslogd alters control characters (see iscntrl(3)). They are always replaced with their “^x” equivalent.

-A  Ordinarily, syslogd tries to send the message to only one address even if the host has more than one A or AAAA record. If this option is specified, syslogd tries to send the message to all addresses.

-a peer
    Allow peers to log to this syslogd using UDP datagrams. Multiple -a options may be specified. Any -a option is ignored if the -s option is also specified.

    The peer argument may be any of the following:

    address[/len][:service]
        Accept datagrams from IP address, which can be specified as an IPv4 address or as an IPv6 address enclosed with ‘[’ and ‘’]. If specified, service is the name or port number of an UDP service (see services(5)) the source packet must belong to. A service of ‘*’ accepts UDP packets from any source port. The default service is ‘syslog’. If address is an IPv4 address, a missing prefix len will be substituted by the historic class A or class B netmasks if address belongs in the address range of class A or B, respectively, or by' /24 otherwise. If address is an IPv6 address, a missing prefix len will be substituted by 128.

    domainname[:service]
        Accept datagrams where the reverse address lookup yields domainname for the sender address. The meaning of service is as explained above. domainname can contain special characters of a shell-style pattern such as ‘*’.

-b addr[:port][%iface]
    Bind to, or listen to, a specific address and/or port. By default, syslogd listens to UDP port 514 on all interfaces, unless started in secure (-s) mode. Multiple -b options may be specified to bind to several addresses and/or ports.

    address[:port]
        Hostname or IP address, IPv6 addresses should be enclosed in ‘[’ and ‘’]

    group[:port][%iface]
        Join the given multicast group on the optional inbound interface. If ‘%iface’ is omitted, the kernel will rely on the routing table to determine which interface to listen to, which is usually not what you want

    :port
        Service name or UDP port number, see services(5). The default service is ‘syslog’ (UDP/514)

    Both unicast IP and multicast group addresses are supported. Multicast groups are "joined" using an OS-level setsockopt() call, most operating systems translate this to IGMP/MLD membership reports on the network.

-C file
    File to use for caching last read kernel sequence number from /dev/kmsg, default: /run/syslogd.cache. If syslogd cannot write to, or read from, this file it will cause repeated kernel log messages when restarting syslogd.

    Note: syslogd relies on this file being removed at system reboot. The default location depends on the system and how syslogd was configured.

-c  Disable the compression of repeated instances of the same line into a single line of the form “last message repeated N times” when the output is a pipe to another program. If specified twice, disable this compression in all cases.

-d  Put syslogd into debugging mode. This is probably only of use to developers working on syslogd. See the DEBUGGING section for more information.

-f file
    Specify the path name of an alternate configuration file; the default is /etc/syslog.conf.

-F  Run syslogd in the foreground, rather than going into daemon mode. This is useful if some other process uses fork(2) and exec(3) to run syslogd, and wants to monitor when and how it exits.

-H  When logging remote messages use hostname from the message (if supplied) instead of using address from which the message was received.

-K  Disable kernel logging. Useful in container use-cases where kernel logs har handled by the host system.

-k  Disable the translation of messages received with facility “kern” to facility “user”. Usually the “kern” facility is reserved for messages read directly from /dev/kmsg.

-l  Keep kernel console logging. By default syslogd call klogctl(2) to disable the kernel's logging to console after having opened /dev/kmsg. With this option the kernel's log level can be adjusted using sysctl(8), or the kernel command line, to suit your logging needs to the console.

    Please note, this does not affect logging of kernel messages, see -K, only what the kernel logs to /dev/console. Also, this is only applicable to Linux.

-m interval
    Select the number of minutes between “mark” messages; the default is 20 minutes. Setting this to zero disables log marks. See the BUGS section for more information.

-M size
    Limit (truncate) the UDP payload size in forwarded messages, default: 1024. This value is from RFC3164, which defines a max message length of 1024 bytes. Please note, the message length includes the header, which varies with the length of the hostname field or any RFC5424 fields if that output format is used.

    The lower limit to this setting is 480, which is the minimum a syslog daemon must support. The upper limit is capped at 2048 bytes for a single message, which is the size a daemon should support according to RFC5424.

    Please note, section 3.2 of RFC5426, Transmission of Syslog Messages over UDP, recommends 480 bytes for IPv4 and 1180 bytes for IPv6 to avoid fragmentation.

-n  Disable DNS query for every request.

-p socket
    Specify the path name of an alternate log socket to be used instead; the default is /dev/log. When a single -p option is specified, the default path name is replaced with the specified one. When two or more -p options are specified, the remaining path names are treated as additional log sockets.

-P file
    Specify an alternative file in which to store the process ID. The default is /var/run/syslogd.pid.

-r size[:count]
    Enable built-in support for log rotation of files listed in /etc/syslog.conf. This feature is particularly useful for small and embedded systems that do not want the overhead of cron(8) and logrotate(8).

    The option controls the max size and number of backup files kept by the built-in log-rotation. When present on the command line it activates log rotation of all files with the given maximum size. It is also possible to control log rotate per log file, see syslog.conf(5) for details.

    The size argument takes optional modifiers; k, M, G. E.g., 100M is 100 MiB, 42k is 42 kiB, etc.

    The optional number of files kept include both gzipped files and the first rotated (not zipped) file. The default for this, when omitted, is 5.

    Note: the permissions of the rotated files are kept. Meaning the administrator can create all log files, before starting syslogd the first time, with the permissions needed for the site. However, if the log files do not exist, syslogd will create them with the user and group it runs as and 0644 permissions.

-s  Operate in secure mode. Do not log messages from remote machines. If specified twice, no network socket will be opened at all, which also disables logging to remote machines.

    Secure mode can also be set in syslog.conf(5) using the secure_mode config option. This is more flexible since you can change the option and simply send SIGHUP to activate the changes, instead of having to restart syslogd.

    Note: the command line option always wins, so it must be removed for syslogd to consider the .conf file option instead.

-T  Always use the local time and date for messages instead of the timestamp field in the log message. This applies to both messages received from a remote syslog server and locally originated. Useful if the originating hosts cannot keep time properly or are unable to generate a correct timestamp. See -t for details on the timestamp of (local) kernel messages.

-t  Keep (trust) kernel timestamp.

    On Linux systems the /dev/kmsg timestamp is a monotonic clock, in microseconds, relative to the boot of the system. This timestamp is, among other things, not adjusted for suspend/resume cycles, meaning the kernel logs can start to go out of sync with the rest of the system. This in turn can make it really hard to correlate events.

    syslogd by default only trusts the kernel timestamp when starting up the first time. As soon as the the kernel ring buffer has been emptied, syslogd uses its own current time for each received kernel log message. This option disables that behavior.

-v  Show program version and exit.

The syslogd utility reads its configuration file when it starts up and whenever it receives a hangup signal. For information on the format of the configuration file, see syslog.conf(5).

The syslogd utility creates its process ID file, by default /var/run/syslogd.pid, and stores its process ID there. This can be used to kill or reconfigure syslogd.

The message sent to syslogd should consist of a single line. The message can contain a priority code, which should be a preceding decimal number in angle braces, for example, ‘<5>’. This priority code should map into the priorities defined in the include file <sys/syslog.h>. To log with RFC5424 style messages the priority code must be directly followed by the version number, this is all handled by libsyslog, which is the NetBSD syslogp(3) API included with the sysklogd project.

The date and time for a log message are by default read from the received message. If the format of the timestamp field is incorrect, the time of reception is used instead. See also the -T flag.

SECURITY
There are a number of methods of protecting a machine:

1.  Disabling inet domain sockets will limit risk to the local machine. Use the secure mode flag -s for this.

2.  When secure mode cannot be used, only allow certain remote peers using the -a PEER flag.

3.  Implement kernel firewalling to limit which hosts or networks have access to the 514/UDP socket.

4.  Logging can be directed to an isolated or non-root filesystem which, if filled, will not impair the machine.

5.  Most modern UNIX filesystems can be configured to limit a certain percentage of a filesystem to usage by root only.

DEBUGGING
When debug mode (-d) is enabled syslogd only the first init() is shown. syslogd then prompts you to send SIGUSR1 to continue debugging. The output is very verbose and is probably only useful to developers.

When syslogd receives SIGHUP it reloads its configuration file, and at the end of the init() sequence all log targets are listed with their respective priority per facility, the action and the log format used:

priority
    Bit mapped priorities listed per facility, one priority per facility, starting with kernel as the left-most column.

action
    FILE, remote sink (FORW), WALL, etc. See syslog.conf(5) for details.

args
    The action argument and the log format used. E.g., for FILE actions the log filename, for FORW action the remote host:port. The format is one of; BSD, RFC5424, or RFC3164. The latter is the default except for FORW actions.

SIGNALS
syslogd supports the following signals:

HUP This lets syslogd perform a re-initialization. All open files are closed, the configuration file (see above) is reread and the syslog(3) facility is started again.

TERM
    This tells syslogd to exit gracefully. Flushing any log files to disk.

INT, QUIT
    In debug mode these are ignored. In normal operation they act as SIGTERM.

USR1
    In debug mode this switches debugging on/off. In normal operation it is ignored.

USR2
    syslogd will rotate all files for which rotation is configured when receiving this signal.

For convenience the PID is by default stored in /var/run/syslogd.pid. A script can look for the existence of this file to determine if syslogd is running, and then send signals:

    kill -SIGNAL `cat /var/run/syslogd.pid`

FILES
/etc/syslog.conf
    configuration file. See syslog.conf(5) for more information.
/etc/syslog.d/*.conf
    conventional sub-directory of .conf files read by syslogd.
/etc/syslog.d/50-default.conf
    conventional name for default rules.
/var/run/syslogd.pid
    default process ID file
/var/run/syslogd.cache
    cache of last read sequence number from /dev/kmsg. Please note, syslogd relies on this file being removed at system reboot.
/dev/log
    name of the UNIX domain datagram log socket
/dev/kmsg
    kernel log device

SEE ALSO
logger(1), syslog(3), syslogp(3), services(5), syslog.conf(5),

STANDARDS
syslogd support both RFC3164 and RFC5424, as well as the pre-RFC BSD logging support. It also supports RFC5426, the command line option -M length can be used to ensure no fragmentation occurs.

RFC3164: https://datatracker.ietf.org/doc/html/rfc3164
RFC5424: https://datatracker.ietf.org/doc/html/rfc5424
RFC5426: https://datatracker.ietf.org/doc/html/rfc5426

HISTORY
syslogd was originally ported to Linux by Greg Wettstein <greg@wind.enjellic.com> and the project was named sysklogd when a separate log daemon, klogd, for Linux kernel messages was added.

It was the default syslogd in Debian and Ubuntu, maintained by Martin Schulze <joey@infodrom.org>, who fixed some bugs and added several new features. When Debian replaced sysklogd with rsyslogd the project was abandoned.

In 2018 Joachim Wiberg <troglobit@gmail.com> picked up maintenance. In 2019 the project was revived with fresh DNA strands from both FreeBSD and NetBSD, klogd was removed in v2.1 and the project was then re-licensed under the 3-clause BSD license, like its brethren.

The syslogd utility first appeared in 4.3BSD.

BUGS
The ability to log messages received in UDP packets is equivalent to an unauthenticated remote disk-filling service, and should probably be disabled (-s) by default. (The shipped systemd unit file disables this by default.) See also SECURITY for more information on this. A future version of syslogd may include support for TLS, RFC5425, which includes authentication of both senders and receivers. For now there is the -a option, which is strongly recommended when operating as a remote sink.

The -a matching algorithm does not pretend to be very efficient; use of numeric IP addresses is faster than domain name comparison. Since the allowed peer list is being walked linearly, peer groups where frequent messages are being anticipated from should be put early into the -a list.

The mark interval, as controlled by the -m interval option, relies on an internal timer with 30 second granularity. Every 30 seconds syslogd will attempt to log the text -- MARK -- with (the internal) facility mark and priority info. Every log target is traversed, if at least INTV minutes have passed since the log target was written to, the mark is logged. Hence, it may be off by up to 30 seconds, this is by design.

As mentioned in the DESCRIPTION, syslogd transparently supports the standard C library syslog(3) API. If a binary linked to the standard C libraries does not operate correctly, this should be reported as a bug to the project's tracker: https://github.com/troglobit/sysklogd/issues