To avoid denial of service attacks when using connection-oriented protocols, the number of simultaneously accepted connections should be limited. This can be achieved using the max-connections()
parameter. The default value of this parameter is quite strict, you might have to increase it on a busy system.
unix-stream() and unix-dgram() source options
These two drivers behave similarly: they open an AF_UNIX
socket and start listening on it for messages. The following options can be specified for these drivers:
Description: Enable creating non-existing directories when creating the socket files.
Description: Specifies the characterset (encoding, for example UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l command. For details on how encoding affects the size of the message, see the section called “Message size and encoding”.
Description: Specifies the log parsing options of the source.
-
assume-utf8: The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
-
dont-store-legacy-msghdr: By default, syslog-ng stores the original incoming header of the log message. This is useful of the original format of a non-syslog-compliant message must be retained (syslog-ng automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
-
empty-lines: Use the empty-lines
flag to keep the empty lines of the messages. By default, syslog-ng PE removes empty lines automatically.
-
expect-hostname: If the expect-hostname
flag is enabled, syslog-ng PE will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
-
kernel: The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
-
no-hostname: Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way syslog-ng PE assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell { network(port(2000) flags(no-hostname)); };
-
no-multi-line: The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the rltp
, syslog()
, network()
, unix-dgram()
drivers support multi-line messages.
-
no-parse: By default, syslog-ng PE parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The syslog-ng PE application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MSG part of the syslog message. This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, syslog-ng PE generates a new syslog header (timestamp, host, and so on) automatically. Note that since flags(no-parse)
disables message parsing, it interferes with other flags, for example, disables flags(no-multi-line)
.
-
syslog-protocol: The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
-
validate-utf8: The validate-utf8
flag enables encoding-verification for messages formatted according to the new IETF syslog standard (for details, see the section called “IETF-syslog messages”). If theBOMcharacter is missing, but the message is otherwise UTF-8 compliant, syslog-ng automatically adds the BOM character to the message.
Description: Set the gid of the socket.
Description: Replaces the ${HOST} part of the message with the parameter string.
Description: Selects whether to keep connections open when syslog-ng is restarted, cannot be used with unix-dgram()
.
Description: Specifies whether syslog-ng should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
|
Caution:
To use the S_ macros, the keep-timestamp() option must be enabled (this is the default behavior of syslog-ng PE). |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
Description: The size of the initial window, this value is used during flow control. If the max-connections()
option is set, the log-iw-size()
will be divided by the number of connections, otherwise log-iw-size()
is divided by 10 (the default value of the max-connections()
option). The resulting number is the initial window size of each connection. For optimal performance when receiving messages from syslog-ng PE clients, make sure that the window size is larger than the flush-lines()
option set in the destination of your clients.
Example 6.42. Initial window size of a connection
If log-iw-size(1000)
and max-connections(10)
, then each connection will have an initial window size of 100.
log-prefix() (DEPRECATED)
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux. NOTE: This option is deprecated. Use program-override()
instead.
Description: Limits the number of simultaneously open connections. Cannot be used with unix-dgram()
.
Description: Use the multi-line-garbage()
option when processing multi-line messages that contain unneeded parts between the messages. Specify a string or regular expression that matches the beginning of the unneeded message parts. If the multi-line-garbage()
option is set, syslog-ng PE ignores the lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
. See also the multi-line-prefix()
option.
When receiving multi-line messages from a source when the multi-line-garbage()
option is set, but no matching line is received between two lines that match multi-line-prefix()
, syslog-ng PE will continue to process the incoming lines as a single message until a line matching multi-line-garbage()
is received.
|
Caution:
If the multi-line-garbage() option is set, syslog-ng PE discards lines between the line matching the multi-line-garbage() and the next line matching multi-line-prefix() . |
|
NOTE:
Starting with syslog-ng PE version 3.2.1, a message is considered complete if no new lines arrive to the message for 10 seconds, even if no line matching the multi-line-garbage() option is received. |
This option is not available for the unix-dgram
driver.
Description: Use the multi-line-prefix()
option to process multi-line messages, that is, log messages that contain newline characters (for example, Tomcat logs). Specify a string or regular expression that matches the beginning of the log messages. Use as simple regular expressions as possible, because complex regular expressions can severely reduce the rate of processing multi-line messages. If the multi-line-prefix()
option is set, syslog-ng PE ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. See also the multi-line-garbage()
option.
|
NOTE:
Starting with syslog-ng PE version 3.2.1, a message is considered complete if no new lines arrive to the message for 10 seconds, even if no line matching the multi-line-garbage() option is received. |
|
TIP:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the ${MESSAGE} macro, use the following: $(indent-multi-line ${MESSAGE}) . This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example: destination d_file {
file ("/var/log/messages"
template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") );
};
For details on using templates, see the section called “Templates and macros”.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the flags(no-multi-line) option in the source. |
Example 6.43. Processing Tomcat logs
The log messages of the Apache Tomcat server are a typical example for multi-line log messages. The messages start with the date and time of the query in the YYYY.MM.DD HH:MM:SS
format, as you can see in the following example.
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use<null>:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1138)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1206 ms
2010.06.09. 12:45:08 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
2010.06.09. 12:45:09 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
To process these messages, specify a regular expression matching the timestamp of the messages in the multi-line-prefix()
option. Such an expression is the following:
source s_file{ file("/var/log/tomcat6/catalina.2010-06-09.log" follow-freq(0) multi-line-prefix("[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.") flags(no-parse));
};
Note that the flags(no-parse)
is needed to avoid syslog-ng PE trying to interpret the date in the message.
This option is not available for the unix-dgram
driver.
Description: Instruct syslog-ng to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe()
, unix-dgram
, and unix-stream
drivers.
Description: Set the uid of the socket.
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. (HP-UX uses 2048 bytes). The syslog-ng PE application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, syslog-ng will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
Description: Set the permission mask. For octal numbers prefix the number with '0', for example: use 0755 for rwxr-xr-x.
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
Description: Enables keep-alive messages, keeping the socket open. This only effects TCP and UNIX-stream sockets. For details, see the socket(7) manual page.
Description: Specifies the size of the socket receive buffer in bytes. For details, see the socket(7) manual page.
|
Caution:
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the syslog-ng PE server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf() option of the source is increased. In such cases, you will need to increase the net.core.rmem_max parameter of the host (for example, to 1024000 ), but do not modify net.core.rmem_default parameter.
As a general rule, increase the so-rcvbuf() so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf() at least to 2 097 152 bytes. |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example tags("dmz", "router")
. This option is available only in syslog-ng 3.1 and later.
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
The timezone can be specified as using the name of the (for example time-zone("Europe/Budapest")
), or as the timezone offset in +/-HH:MM format (for example +01:00
). On Linux and UNIX platforms, the valid timezone names are listed under the /usr/share/zoneinfo
directory.
Description: If the value of this option is yes
, then the PID value of the message will be overridden with the PID of the running syslog-ng process.