A destination is where a log message is sent if the filtering rules match. Similarly to sources, destinations consist of one or more drivers, each defining where and how messages are sent.
![]() |
Tip |
|---|---|
If no drivers are defined for a destination, all messages sent to the destination are discarded. This is equivalent to omitting the destination from the log statement. |
To define a destination, add a destination statement to the syslog-ng configuration file using the following syntax:
destination <identifier> {
destination-driver(params); destination-driver(params); ... };
![]() |
Example 3.16. A simple destination statement |
|---|---|
|
The following destination statement sends messages to the TCP port
destination d_demo_tcp { tcp("10.1.2.3" port(1999)); };
If name resolution is configured, the hostname of the target server can be used as well. destination d_tcp { tcp("target_host" port(1999); localport(999)); };
|
The following table lists the destination drivers available in syslog-ng.
| Name | Description |
|---|---|
| file() | Writes messages to the specified file. |
logstore()*
|
Writes messages to the specified binary logstore file.
*Available only in syslog-ng Premium
Edition. |
| fifo(), pipe() | Writes messages to the specified named pipe. |
| program() | Forks and launches the specified program, and sends messages to its standard input. |
| sql() | Sends messages into an SQL database. In addition to the standard
syslog-ng packages, the sql() destination
requires database-specific packages to be installed. Refer to the
section appropriate for your platform in Chapter 4, Installing syslog-ng. |
| syslog() | Sends messages to the specified remote host using the IETF-syslog protocol. The IETF standard supports message transport using the UDP, TCP, and TLS networking protocols. |
| tcp() and tcp6() | Sends messages to the specified TCP port of a remote host using the BSD-syslog protocol over IPv4 and IPv6, respectively. |
| udp() and udp6() | Sends messages to the specified UDP port of a remote host using the BSD-syslog protocol over IPv4 and IPv6, respectively. |
| unix-dgram() | Sends messages to the specified unix socket in
SOCK_DGRAM style (BSD). |
| unix-stream() | Sends messages to the specified unix socket in
SOCK_STREAM style (Linux). |
| usertty() | Sends messages to the terminal of the specified user, if the user is logged in. |
Table 3.3. Destination drivers available in syslog-ng
For detailed list of driver parameters, see Section 8.2, “Destination drivers”.
The file driver is one of the most important destination drivers in syslog-ng. It allows to output messages to the specified text file, or to a set of files.
The destination filename may include macros which get expanded when the message is
written, thus a simple file() driver may create several
files. For more information on available macros see Section 8.5, “Macros”.
If the expanded filename refers to a directory which does not exist, it will be
created depending on the create_dirs() setting (both global
and a per destination option).
The file() has a single required parameter that specifies
the filename that stores the log messages. For the list of available optional
parameters, see Section 8.2.1, “file()”.
Declaration:
file(filename options());
![]() |
Note |
|---|---|
When using the |
![]() |
Warning |
|---|---|
|
Since the state of each created file must be tracked by syslog-ng, it consumes
some memory for each file. If no new messages are written to a file within 60
seconds (controlled by the Exploiting this, a DoS attack can be mounted against the system. If the number of possible destination files and its needed memory is more than the amount available on the syslog-ng server. The most suspicious macro is |
The logstore() driver stores log messages in binary files
that can be encrypted, compressed, checked for integrity, and timestamped by an
external Timestamping Authority (TSA). Otherwise, it is very similar to the
file() destination.
Logstore files consist of individual chunks, every chunk can be encrypted, compressed, and timestamped separately. Chunks contain log message data, chunk size defaults to 128k (about 1MB worth of compressed logs).
To display the contents of a logstore file, use the logcat command supplied with syslog-ng, e.g., logcat /var/log/messages.lgs. To display the contents of encrypted log files, specify the private key of the certificate used to encrypt the file, e.g., logcat -k private.key /var/log/messages.lgs. The contents of the file are sent to the standard output, so it is possible to use grep and other tools to find particular log messages, e.g., logcat /var/log/messages.lgs |grep 192.168.1.1.
Every record that is stored in the logstore has a unique record ID. The logcat application can quickly jump to a specified record using the -- seek option.
For files that are in use by syslog-ng, the last chunk that is open cannot be
read. Chunks are closed when their size reaches the limit set in the
chunk_size parameter, or when the time limit set in the
chunk_time parameter expires and no new message arrives.
The syslog-ng PE application generates an SHA-1 hash for every chunk to verify the
integrity of the chunk. The hashes of the chunks are chained together to prevent
injecting chunks into the logstore file. The syslog-ng application can encrypt the
logstore using the aes128 algorithm in CBC mode; the hashing
(HMAC) algorithm is hmac-sha1. Currently it is not possible
to use other algorithms.
![]() |
Warning |
|---|---|
If the syslog-ng Premium Edition application or the computer crashes, an unclosed chunk remains at the end of the file. This chunk is marked as broken, its data stays there but is not shown by logcat. |
The destination filename may include macros which get expanded when the message is
written, thus a simple logstore() driver may create several
files. For more information on available macros see Section 8.5, “Macros”.
If the expanded filename refers to a directory which does not exist, it will be
created depending on the create_dirs() setting (both global
and a per destination option).
The logstore() has a single required parameter that
specifies the filename that stores the log messages. For the list of available
optional parameters, see Section 8.2.2, “logstore()”.
Declaration:
logstore(filename options());
![]() |
Note |
|---|---|
When using the |
![]() |
Warning |
|---|---|
|
Since the state of each created file must be tracked by syslog-ng, it consumes
some memory for each file. If no new messages are written to a file within 60
seconds (controlled by the Exploiting this, a DoS attack can be mounted against the system. If the number of possible destination files and its needed memory is more than the amount available on the syslog-ng server. The most suspicious macro is |
The pipe() driver sends messages to a named pipe like
/dev/xconsole.
The pipe driver has a single required parameter, specifying the filename of the pipe to open. The filename can include macros. For the list of available optional parameters, see Section 8.2.3, “pipe()”.
Declaration:
pipe(filename);
![]() |
Warning |
|---|---|
As of syslog-ng Open Source Edition 3.0.2, pipes are created automatically. In earlier versions, you had to create the pipe using the mkfifo(1) command. |
The program() driver starts an external application or
script and sends the log messages to its standard input
(stdin).
The program() driver has a single required parameter,
specifying a program name to start. The program is executed with the help of the
current shell, so the command may include both file patterns and I/O redirections.
For the list of available optional parameters, see Section 8.2.4, “program()”.
Declaration:
program(command_to_run);
![]() |
Note |
|---|---|
The syslog-ng application automatically restarts the external program if it exits for reliability reasons. However it is not recommended to launch programs for single messages, because if the message rate is high, launching several instances of an application might overload the system, resulting in Denial of Service. |
Note that the message format does not include the priority and facility values by default. To add these values, specify a template for the program destination, as shown in the following example.
The sql() driver sends messages into an SQL database.
Currently the Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL, and SQLite databases
are supported.
![]() |
Note |
|---|---|
In order to use the |
The sql() driver has the following required parameters:
Table 3.4. Required parameters of the sql() driver
For the list of available optional parameters, see Section 8.2.5, “sql()”.
Declaration:
sql(database_type host_parameters database_parameters [options]);
![]() |
Warning |
|---|---|
|
The syslog-ng application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists. Currently the syslog-ng application has default schemas for the different databases and uses these defaults if the database schema (e.g., columns and column types) is not defined in the configuration file. However, these schemas will be deprecated and specifying the exact database schema will be required in later versions of syslog-ng. |
![]() |
Note |
|---|---|
|
In addition to the standard syslog-ng packages, the
The |
The table and value parameters can
include macros to create tables and columns dynamically (see Section 8.5, “Macros” for details).
![]() |
Warning |
|---|---|
When using macros in table names, note that some databases limit the maximum allowed length of table names. Consult the documentation of the database for details. |
Inserting the records into the database is performed by a separate thread. The syslog-ng application automatically performs the escaping required to insert the messages into the database.
The Oracle sql destination has some special aspects that are important to note.
The hostname of the database server is set in the
tnsnames.ora file, not in the
host parameter of the
sql() destination.
Make sure to set the Oracle-related environment variables properly, so
syslog-ng and the Oracle client will find the file. The following
variables must be set: ORACLE_BASE,
ORACLE_HOME, and
ORACLE_SID. See the documentation of the Oracle
Instant Client for details.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns
must be explicitly set for the Oracle destination. The column used to
store the text part of the syslog messages should be able to store
messages as long as the longest message permitted by syslog-ng,
therefore it is usually recommended to use the
varchar2 or clob column
type. (The maximum length of the messages can be set using the
log_msg_size() option.) See the following
example for details.
The mssql database driver can access Microsoft SQL
(MSSQL) destinations. This driver has some special aspects that are important to
note.
The date format used by the MSSQL database must be explicitly set in
the /etc/locales.conf file of the syslog-ng server.
See the following example for details.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns
must be explicitly set for the MSSQL destination. The column used to
store the text part of the syslog messages should be able to store
messages as long as the longest message permitted by syslog-ng. The
varchar column type can store maximum 4096
bytes-long messages. The maximum length of the messages can be set using
the log_msg_size() option. See the following
example for details.
Remote access for SQL users must be explicitly enabled on the Microsoft Windows host running the Microsoft SQL Server. See Section 4.6, “Configuring Microsoft SQL Server to accept logs from syslog-ng” for details.
The syslog() driver sends messages to a remote host (e.g.,
a syslog-ng server or relay) on the local intranet or internet using the new
standard syslog protocol developed by IETF (see Section 2.18.2, “IETF-syslog messages” for details about the new protocol). The
protocol supports sending messages using the UDP, TCP, or the encrypted TLS
networking protocols.
The required arguments of the driver are the address of the destination host (where messages should be sent). The transport method (networking protocol) is optional, syslog-ng uses the TCP protocol by default. For the list of available optional parameters, see Section 8.2.6, “syslog()”.
Declaration:
syslog(host transport [options]);
![]() |
Note |
|---|---|
Note that the |
The udp transport method automatically sends multicast
packets if a multicast destination address is specified. The
tcp and tls methods do not support
multicasting.
![]() |
Note |
|---|---|
The default ports for the different transport protocols are as follows: UDP — 514; TLS — 6514. |
![]() |
Example 3.25. Using the syslog() driver |
|---|---|
destination d_tcp { syslog(ip"10.1.2.3" transport("tcp") port(1999); localport(999)); };
If name resolution is configured, the hostname of the target server can be used as well. destination d_tcp { syslog(ip"target_host" transport("tcp") port(1999); localport(999)); };
Send the log messages using TLS encryption and use mutual authentication. See Section 8.10, “TLS options” for details on the encryption and authentication options. destination d_syslog_tls{
syslog("10.100.20.40"
transport("tls")
port(6514)
tls(peer-verify(required-trusted)
ca_dir('/opt/syslog-ng/etc/syslog-ng/keys/ca.d/')
key_file('/opt/syslog-ng/etc/syslog-ng/keys/client_key.pem')
cert_file('/opt/syslog-ng/etc/syslog-ng/keys/client_certificate.pem'))
);};
|
The tcp(), tcp6(),
udp(), and udp6() drivers send
messages to another host (e.g., a syslog-ng server or relay) on the local intranet
or internet using the UDP or TCP protocol. The tcp6() and
udp6() drivers use the IPv6 network protocol.
All four drivers have a single required parameter specifying the destination host address, where messages should be sent. For the list of available optional parameters, see Section 8.2.7, “tcp(), tcp6(), udp(), and udp6(),”.
The udp() and udp6() drivers
automatically send multicast packets if a multicast destination address is
specified. The tcp() and tcp6()
drivers do not support multicasting.
Declaration:
tcp(host [options]);
udp(host [options]);
tcp6(host [options]);
udp6(host [options]);
The unix-stream() and unix-dgram()
drivers send messages to a UNIX domain socket in either
SOCK_STREAM or SOCK_DGRAM mode.
Both drivers have a single required argument specifying the name of the socket to connect to. For the list of available optional parameters, see Section 8.2.8, “unix-stream() & unix-dgram()”.
Declaration:
unix-stream(filename [options]);
unix-dgram(filename [options]);
This driver writes messages to the terminal of a logged-in user.
The usertty() driver has a single required argument,
specifying a username who should receive a copy of matching messages.
Declaration:
usertty(username);
The usertty() does not have any further options nor does it
support templates.
![]() |
Example 3.28. Using the usertty() driver |
|---|---|
destination d_usertty { usertty("root"); }; |
© 2007-2008 BalaBit IT Security
Please send your comments or documentation bugs to: documentation@balabit.com