4.1. Procedure – Configuring syslog-ng on client hosts


To configure syslog-ng on a client host, complete the following steps.


  1. Install the syslog-ng application on the host. For details installing syslog-ng on specific operating systems, see Chapter 3, Installing syslog-ng.

  2. Configure the local sources to collect the log messages of the host. Starting with version 3.2, syslog-ng OSE automatically collects the log messages that use the native system logging method of the platform, for example, messages from /dev/log on Linux, or /dev/klog on FreeBSD. For a complete list of messages that are collected automatically, see Section 6.15, system: Collecting the system-specific log messages of a platform.

    To configure syslog-ng OSE, edit the syslog-ng.conf file with any regular text editor application. The location of the configuration file depends on how you installed syslog-ng OSE. Native packages of a platform (like the ones downloaded from Linux repositories) typically place the configuration file under the /etc/syslog-ng/ directory.

    Add sources to collect the messages from your log files. File sources look like this:

    source s_myfilesource {
            file("/var/log/myapplication.log" follow-freq(1)); };

    Name every source uniquely. For details on configuring file sources, see Section 6.3, file: Collecting messages from text files.


    Many applications send log messages to logfiles by default (for example, the Roundcube webmail client, or the ProFTPD FTP server), but can be configured to send them to syslog instead. If possible, it is recommended to reconfigure the application that way.


    The default configuration file of syslog-ng OSE collects platform-specific log messages and the internal log messages of syslog-ng OSE.

    source s_local {
  3. Create a network destination that points directly to the syslog-ng server, or to a local relay. The network destination greatly depends on the protocol that your log server or relay accepts messages. Many systems still use the legacy BSD-syslog protocol (RFC3162) over the unreliable UDP transport:

    destination d_network { network("" transport("udp")); };

    However, if possible, use the much more reliable IETF-syslog protocol over TCP transport:

    destination d_network { syslog("" transport("tcp")); };
  4. Create a log statement connecting the local sources to the syslog-ng server or relay. For example:

    log {
            source(s_local); destination(d_network); };
  5. If the logs will also be stored locally on the host, create local file destinations.


    The default configuration of syslog-ng OSE places the collected messages into the /var/log/messages file:

    destination d_local {
        file("/var/log/messages"); };
  6. Create a log statement connecting the local sources to the file destination.


    The default configuration of syslog-ng OSE has only one log statement:

    log {
        source(s_local); destination(d_local); };
  7. Set filters, macros and other features and options (for example TLS encryption) as necessary.

    Example 4.1. The default configuration file of syslog-ng OSE

    The following is the default configuration file of syslog-ng OSE 3.12. It collects local log messages and the log messages of syslog-ng OSE and saves them in the /var/log/messages file.

    @version: 3.12
    @include "scl.conf"
    source s_local { system(); internal(); };
    destination d_local {
                file("/var/log/messages"); };
    log { source(s_local); destination(d_local); };
    Example 4.2. A simple configuration for clients

    The following is a simple configuration file that collects local log messages and forwards them to a logserver using the IETF-syslog protocol.

    @version: 3.12
    @include "scl.conf"
    source s_local { system(); internal(); };
    destination d_syslog_tcp {
                 syslog("" transport("tcp") port(2010)); };
    log { source(s_local);destination(d_syslog_tcp); };