The file driver outputs 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”.
![]() |
Warning |
|---|---|
|
When creating several thousands separate log files, syslog-ng might not be able to
open the required number of files. This might happen for example when using the
|
The file() destination has the following options:
| Name | Type | Default | Description |
|---|---|---|---|
| create_dirs() | yes or no | no | Enable creating non-existing directories. |
| dir_group() | string | root | The group of directories created by syslog-ng. |
| dir_owner() | string | root | The owner of directories created by syslog-ng. |
| dir_perm() | number | 0600 | The permission mask of directories created by syslog-ng. Log
directories are only created if a file after macro expansion refers
to a non-existing directory, and directory creation is enabled (see
the create_dirs() option below). For octal
numbers prefix the number with 0, e.g., use
0755 for
rwxr-xr-x. |
| flags() | no_multi_line, syslog-protocol | empty set |
Flags influence the behavior of the driver. The The |
| flush_lines() | number | Use global setting. | Specifies how many lines are flushed to a destination at a time.
Syslog-ng waits for this number of lines to accumulate and sends them off in
a single batch. Setting this number high increases throughput as fully
filled frames are sent to the network, but also increases message latency.
The latency can be limited by the use of the
flush_timeout option. |
| flush_timeout() | time in milliseconds | Use global setting. | Specifies the time syslog-ng waits for lines to accumulate in its output
buffer. See the flush_lines option for more
information. |
| frac_digits() | number | 0 | The syslog-ng application can store fractions of a second in the
timestamps according to the ISO8601 format.. The
frac_digits() parameter specifies the number of
digits stored. The digits storing the fractions are padded by zeros if the
original timestamp of the message specifies only seconds. Fractions can
always be stored for the time the message was received. Note that syslog-ng
can add the fractions to non-ISO8601 timestamps as well. |
| fsync() | yes or no | no | Forces an fsync() call on the destination fd after
each write. Note: enabling this option may seriously degrade
performance. |
| group() | string | root | Set the group of the created file to the one specified. |
local_time_zone()
|
name of the timezone or the timezone offset | The local timezone. | Sets the timezone used when expanding filename and tablename templates.
The timezone can be specified as using the name of the (e.g.,
time_zone("Europe/Budapest")), or as the timezone
offset (e.g., +01:00). The valid timezone names are
listed under the /usr/share/zoneinfo directory. |
| log_fifo_size() | number | Use global setting. | The number of entries in the output buffer (output fifo). |
overwrite_if_older()
|
number | 0 | If set to a value higher than 0, syslog-ng checks when the file
was last modified before starting to write into the file. If the
file is older than the specified amount of time (in seconds), then
syslog-ng removes the existing file and opens a new file with the
same name. In combination with e.g., the
$WEEKDAY macro, this can be used for simple
log rotation, in case not all history has to be kept. (Note that in
this weekly log rotation example if its Monday 00:01, then the file
from last Monday is not seven days old, because it was probably last
modified shortly before 23:59 last Monday, so it is actually not
even six days old. So in this case, set the
overwrite_if_older() parameter to
a-bit-less-than-six-days, for example, to
518000 seconds. |
| owner() | string | root | Set the owner of the created file to the one specified. |
| perm() | number | 0600 | The permission mask of the file if it is created by syslog-ng.
For octal numbers prefix the number with 0,
e.g., use 0755 for
rwxr-xr-x. |
| suppress() | seconds | 0 (disabled) | If several identical log messages would be sent to the destination
without any other messages between the identical messages (for example, an
application repeated an error message ten times), syslog-ng can suppress the
repeated messages and send the message only once, followed by the
Last message repeated n times. message. The
parameter of this option specifies the number of seconds syslog-ng waits for
identical messages. |
| template() | string | A format conforming to the default logfile format. | Specifies a template defining the logformat to be used in the
destination. Macros are described in Section 8.5, “Macros”.
Please note that for network destinations it might not be appropriate to
change the template as it changes the on-wire format of the syslog protocol
which might not be tolerated by stock syslog receivers (like
syslogd or syslog-ng itself). For network
destinations make sure the receiver can cope with the custom format defined.
|
| template_escape() | yes or no | no | Turns on escaping ' and "
in templated output files. This is useful for generating SQL statements and
quoting string contents so that parts of the log message are not interpreted
as commands to the SQL server. |
| throttle() | number | 0 | Sets the maximum number of messages sent to the destination per second.
Use this output-rate-limiting functionality only when using disk-buffer as
well to avoid the risk of losing messages. Specifying
0 or a lower value sets the output limit to
unlimited. |
| time_zone() | timezone in +/-HH:MM format | unspecified | Convert timestamps to the timezone specified by this option. If this option is not set then the original timezone information in the message is used. |
| ts_format() | rfc3164, bsd, rfc3339, iso | rfc3164 | Override the global timestamp format (set in the global
ts_format() parameter) for the specific
destination. See also Section 7.7, “A note on timezones and timestamps”. |
Table 8.8. Options for file()
© 2007-2010 BalaBit IT Security
Please send your comments or documentation bugs to: documentation@balabit.com