xref: /netbsd-src/usr.sbin/syslogd/syslog.conf.5 (revision d48f14661dda8638fee055ba15d35bdfb29b9fa8)
1.\"	$NetBSD: syslog.conf.5,v 1.13 2004/11/19 18:48:43 wiz Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     from: @(#)syslog.conf.5	8.1 (Berkeley) 6/9/93
31.\"
32.Dd November 18, 2004
33.Dt SYSLOG.CONF 5
34.Os
35.Sh NAME
36.Nm syslog.conf
37.Nd
38.Xr syslogd 8
39configuration file
40.Sh DESCRIPTION
41The
42.Nm
43file is the configuration file for the
44.Xr syslogd 8
45program.
46It consists of blocks of lines separated by
47.Em program
48and
49.Em hostname
50specifications, with each line containing two fields: the
51.Em selector
52field which specifies the types of messages and priorities to which the
53line applies, and an
54.Em action
55field which specifies the action to be taken if a message
56.Xr syslogd 8
57receives matches the selection criteria.
58The
59.Em selector
60field is separated from the
61.Em action
62field by one or more tab characters.
63.Pp
64The
65.Em Selectors
66function
67are encoded as a
68.Em facility ,
69a period
70.Pq Sq \&. ,
71an optional set of comparison flags
72.Pq Bo ! Bc Bq \*[Lt]=\*[Gt] ,
73and a
74.Em level ,
75with no intervening white-space.
76Both the
77.Em facility
78and the
79.Em level
80are case insensitive.
81.Pp
82The
83.Em facility
84describes the part of the system generating the message, and is one of
85the following keywords: auth, authpriv, cron, ftp, daemon, kern, lpr,
86mail, mark, news, syslog, user, uucp and local0 through local7.
87These keywords (with the exception of mark) correspond to the
88similar
89.Dq Dv LOG_
90values specified to the
91.Xr openlog 3
92and
93.Xr syslog 3
94library routines.
95.Pp
96The
97.Em comparison flags
98may be used to specify exactly what levels are logged.
99If unspecified, the default comparison is
100.Sq \*[Gt]=
101.Pq greater than or equal to ,
102or, if the
103.Fl U
104option is passed to
105.Xr syslogd 8 ,
106.Sq =
107.Pq equal to .
108Comparison flags beginning with
109.So ! Sc
110will have their logical sense inverted.
111Thus,
112.Sq !=info
113means all levels except info and
114.Sq !notice
115has the same meaning as
116.Sq \*[Lt]notice .
117.Pp
118The
119.Em level
120describes the severity of the message, and is a keyword from the
121following ordered list (higher to lower): emerg, alert, crit, err,
122warning, notice, info and debug.
123These keywords correspond to the
124similar
125.Pq Dv LOG_
126values specified to the
127.Xr syslog 3
128library routine.
129.Pp
130Each block of lines is separated from the previous block by a
131.Em program
132or
133.Em hostname
134specification.
135A block will only log messages corresponding to the most recent
136.Em program
137and
138.Em hostname
139specifications given.
140Consider the case of a block that selects
141.Ql pppd
142as the
143.Em program ,
144directly followed by a block that selects messages from the
145.Em hostname
146.Ql dialhost .
147The second block will log only messages from the
148.Xr pppd 8
149program from the host
150.Sq dialhost .
151.Pp
152A
153.Em program
154specification of the form
155.Ql #!+prog1,prog2
156or
157.Ql !+prog1,prog2
158will cause subsequent blocks to be applied to messages logged by the
159specified programs.
160A
161.Em program
162specification of the form
163.Ql #!-prog1,prog2
164or
165.Ql !-prog1,prog2
166will cause subsequent blocks to be applied to messages logged by programs
167other than the ones specified.
168A
169.Em program
170specification of the form
171.Ql #!prog1,prog2
172or
173.Ql !prog1,prog2
174is equivalent to
175.Ql !+prog1,prog2 .
176Program selectors may also match kernel-generated messages.
177For example, a program specification of
178.Ql !+subsys
179will match kernel-generated messages of the form
180.Ql subsys: here is a message .
181The special specification
182.Ql !*
183will cause subsequent blocks to apply to all programs.
184.Pp
185A
186.Em hostname
187specification of the form
188.Ql #+host1,host2
189or
190.Ql +host1,host2
191will cause subsequent blocks to be applied to messages received from
192the specified hosts.
193A
194.Em hostname
195specification of the form
196.Ql #-host1,host2
197or
198.Ql -host1,host2
199will cause subsequent blocks to be applied to messages from hosts other
200than the ones specified.
201If the hostname is given as
202.Ql @ ,
203the local hostname will be used.
204The special specification
205.Ql +*
206will cause subsequent blocks to apply to all hosts.
207.Pp
208See
209.Xr syslog 3
210for a further descriptions of both the
211.Em facility
212and
213.Em level
214keywords and their significance.
215It is preferred that selections be made based on
216.Em facility
217rather than
218.Em program ,
219since the latter can vary in a networked environment.
220However, there are cases where a
221.Em facility
222may be too broadly defined.
223.Pp
224If a received message matches the specified
225.Em facility ,
226and the specified
227.Em level
228comparison is true,
229and the first word in the message after the date matches the
230.Em program ,
231the action specified in the
232.Em action
233field will be taken.
234.Pp
235Multiple
236.Em selectors
237may be specified for a single
238.Em action
239by separating them with semicolon
240.Pq Sq \&;
241characters.
242It is important to note, however, that each
243.Em selector
244can modify the ones preceding it.
245.Pp
246Multiple
247.Em facilities
248may be specified for a single
249.Em level
250by separating them with comma
251.Pq Sq \&,
252characters.
253.Pp
254An asterisk
255.Pq Sq \&*
256can be used to specify all
257.Em facilities
258or all
259.Em levels .
260.Pp
261The special
262.Em facility
263.Dq mark
264receives a message at priority
265.Dq info
266every 20 minutes
267(see
268.Xr syslogd 8 ) .
269This is not enabled by a
270.Em facility
271field containing an asterisk.
272.Pp
273The special
274.Em level
275.Dq none
276disables a particular
277.Em facility .
278.Pp
279The
280.Em action
281field of each line specifies the action to be taken when the
282.Em selector
283field selects a message.
284There are five forms:
285.Bl -bullet
286.It
287A pathname (beginning with a leading slash).
288Selected messages are appended to the file.
289.Pp
290To ensure that kernel messages are written to disk promptly,
291.Xr syslogd 8
292calls
293.Xr fsync 2
294after writing messages from the kernel.
295Other messages are not synced explcitly.
296You may disable syncing of files specified to receive kernel messages
297by prefixing the pathname with a minus sign
298.Ql - .
299Note that use of this option may cause the loss of log information in
300the event of a system crash immediately following the write attempt.
301However, using this option may prove to be useful if your system's
302kernel is logging many messages.
303.It
304A hostname (preceded by an at
305.Pq Sq @
306sign).
307Selected messages are forwarded to the
308.Xr syslogd 8
309program on the named host.
310.It
311A comma separated list of users.
312Selected messages are written to those users
313if they are logged in.
314.It
315An asterisk.
316Selected messages are written to all logged-in users.
317.It
318A vertical bar
319.Pq Sq |
320followed by a command to which to pipe the selected messages.
321The command string is passed to
322.Pa /bin/sh
323for evaluation, so the usual shell metacharacters or input/output
324redirection can occur.
325(Note that redirecting
326.Xr stdio 3
327buffered output from the invoked command can cause additional delays,
328or even lost output data in case a logging subprocess exits with a
329signal.)
330The command itself runs with
331.Em stdout
332and
333.Em stderr
334redirected to
335.Pa /dev/null .
336Upon receipt of a
337.Dv SIGHUP ,
338.Xr syslogd 8
339will close the pipe to the process.
340If the process does not exit voluntarily, it will be sent a
341.Dv SIGTERM
342signal after a grace period of up to 60 seconds.
343.Pp
344The command will only be started once data arrives that should be
345piped to it.
346If the command exits, it will be restarted as necessary.
347.Pp
348If it is desired that the subprocess should receive exactly one line of
349input, this can be achieved by exiting after reading and processing the
350single line.
351A wrapper script can be used to achieve this effect, if necessary.
352Note that this method can be very resource-intensive if many log messages
353are being piped through the filter.
354.Pp
355Unless the command is a full pipeline, it may be useful to
356start the command with
357.Em exec
358so that the invoking shell process does not wait for the command to
359complete.
360Note that the command is started with the UID of the
361.Xr syslogd 8
362process, normally the superuser.
363.El
364.Pp
365Blank lines and lines whose first non-blank character is a hash
366.Pq Sq #
367character are ignored.
368.Sh FILES
369.Bl -tag -width /etc/syslog.conf -compact
370.It Pa /etc/syslog.conf
371The
372.Xr syslogd 8
373configuration file.
374.El
375.Sh EXAMPLES
376A configuration file might appear as follows:
377.Bd -literal
378# Log all kernel messages, authentication messages of
379# level notice or higher and anything of level err or
380# higher to the console.
381# Don't log private authentication messages!
382*.err;kern.*;auth.notice;authpriv.none	/dev/console
383
384# Log anything (except mail) of level info or higher.
385# Don't log private authentication messages!
386*.info;mail.none;authpriv.none		/var/log/messages
387
388# Log daemon messages at debug level only
389daemon.=debug				/var/log/daemon.debug
390
391# The authpriv file has restricted access.
392authpriv.*				/var/log/secure
393
394# Log all the mail messages in one place.
395mail.*					/var/log/maillog
396
397# Everybody gets emergency messages, plus log them on another
398# machine.
399*.emerg					*
400*.emerg					@arpa.berkeley.edu
401
402# Root and Eric get alert and higher messages.
403*.alert					root,eric
404
405# Save mail and news errors of level err and higher in a
406# special file.
407mail,news.err				/var/log/spoolerr
408
409# Pipe all authentication messages to a filter.
410auth.*					|exec /usr/local/sbin/authfilter
411
412# Log kernel messages to a separate file without syncing each message.
413kern.*					-/var/log/kernlog
414
415# Save ftpd transactions along with mail and news.
416!ftpd
417*.*					/var/log/spoolerr
418
419# Send all error messages from a RAID array through a filter.
420!raid0
421kern.err				|exec /usr/local/sbin/raidfilter
422
423# Save pppd messages from dialhost to a separate file.
424!pppd
425+dialhost
426*.*					/var/log/dialhost-pppd
427
428# Save non-local log messages from all programs to a separate file.
429!*
430-@
431*.*					/var/log/foreign
432.Ed
433.Sh SEE ALSO
434.Xr syslog 3 ,
435.Xr syslogd 8
436.Sh HISTORY
437The
438.Nm
439file appeared in
440.Bx 4.3 ,
441along with
442.Xr syslogd 8 .
443.Sh BUGS
444The effects of multiple selectors are sometimes not intuitive.
445For example
446.Dq mail.crit;*.err
447will select
448.Dq mail
449facility messages at
450the level of
451.Dq err
452or higher, not at the level of
453.Dq crit
454or higher.
455