Configuring AxoSyslog on server hosts
Purpose:
To configure AxoSyslog on a server host, complete the following steps.
Steps:
-
Install the AxoSyslog application on the host. For details installing AxoSyslog on specific operating systems, see Install AxoSyslog.
-
Starting with version 3.2, AxoSyslog 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 system: Collect the system-specific log messages of a platform. -
To configure AxoSyslog, edit the
syslog-ng.conf
file with any regular text editor application. The location of the configuration file depends on the platform you are running AxoSyslog, and how you have installed AxoSyslog it.- Native packages of a platform (like the ones downloaded from Linux repositories) typically place the configuration file under the
/etc/syslog-ng/
directory. - Containers: When running AxoSyslog in a container, typically you map an external file to the
/etc/syslog-ng/syslog-ng.conf
file within the container. Check the mapped volumes of your container, and edit the external file. - Kubernetes: If you’re running AxoSyslog in Kubernetes and have installed it with helm, usually you configure AxoSyslog by editing a
values.yaml
file, and redeploying AxoSyslog. Often thesyslog-ng.conf
part is under theconfig.raw
section in thevalues.yaml
file. For details, see Parameters of the AxoSyslog Helm chart.
Configure the network sources that collect the log messages sent by the clients and relays. How the network sources should be configured depends also on the capabilities of your client hosts: many older networking devices support only the legacy BSD-syslog protocol (RFC3164) using UDP transport:
source s_network { syslog(ip(10.1.2.3) transport("udp")); };
However, if possible, use the much more reliable TCP transport:
source s_network { syslog(ip(10.1.2.3) transport("tcp")); };
For other options, see syslog: Collect messages using the IETF-syslog protocol and tcp, tcp6, udp, udp6: OBSOLETE - Collect messages from remote hosts using the BSD syslog protocol.
Note Starting with AxoSyslog version 3.2, thesyslog()
source driver can handle both BSD-syslog (RFC 3164) and IETF-syslog (RFC 5424-26) messages. - Native packages of a platform (like the ones downloaded from Linux repositories) typically place the configuration file under the
-
Create local destinations that will store the log messages, for example, file- or program destinations. The default configuration of AxoSyslog places the collected messages into the
/var/log/messages
file:destination d_local { file("/var/log/messages"); };
If you want to create separate logfiles for every client host, use the
${HOST}
macro when specifying the filename, for example:destination d_local { file("/var/log/messages_${HOST}"); };
For details on further macros and how to use them, see template and rewrite: Format, modify, and manipulate log messages.
-
Create a log statement connecting the sources to the local destinations.
log { source(s_local); source(s_network); destination(d_local); };
-
Set filters, options (for example, TLS encryption) and other advanced features as necessary.
NoteBy default, the AxoSyslog server treats the relayed messages as if they were created by the relay host, not the host that originally sent them to the relay. In order to use the original hostname on the AxoSyslog server, use the
keep-hostname(yes)
option both on the AxoSyslog relay and the AxoSyslog server. This option can be set individually for every source if needed.If you are relaying log messages and want to resolve IP addresses to hostnames, configure the first relay to do the name resolution.
Example: A simple configuration for servers
The following is a simple configuration file for AxoSyslog that collects incoming log messages and stores them in a text file.
@version: 4.9.0 @include "scl.conf" options { time-reap(30); mark-freq(10); keep-hostname(yes); }; source s_local { system(); internal(); }; source s_network { syslog(transport(tcp)); }; destination d_logs { file( "/var/log/syslog-ng/logs.txt" owner("root") group("root") perm(0777) ); }; log { source(s_local); source(s_network); destination(d_logs); };