autofs: Remove BUGS section from autofs(5)
[dragonfly.git] / usr.sbin / syslogd / syslog.conf.5
1 .\" Copyright (c) 1990, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)syslog.conf.5       8.1 (Berkeley) 6/9/93
29 .\" $FreeBSD: head/usr.sbin/syslogd/syslog.conf.5 240409 2012-09-12 16:58:42Z eadler $
30 .\"
31 .Dd September 12, 2012
32 .Dt SYSLOG.CONF 5
33 .Os
34 .Sh NAME
35 .Nm syslog.conf
36 .Nd
37 .Xr syslogd 8
38 configuration file
39 .Sh DESCRIPTION
40 The
41 .Nm
42 file is the configuration file for the
43 .Xr syslogd 8
44 program.
45 It consists of
46 blocks of lines separated by
47 .Em program
48 and
49 .Em hostname
50 specifications (separations appear alone on their lines),
51 with each line containing two fields: the
52 .Em selector
53 field which specifies the types of messages and priorities to which the
54 line applies, and an
55 .Em action
56 field which specifies the action to be taken if a message
57 .Xr syslogd 8
58 receives matches the selection criteria.
59 The
60 .Em selector
61 field is separated from the
62 .Em action
63 field by one or more tab characters or spaces.
64 .Pp
65 Note that if you use spaces as separators, your
66 .Nm
67 might be incompatible with other Unices or Unix-like systems.
68 This functionality was added for ease of configuration
69 (e.g.\& it is possible to cut-and-paste into
70 .Nm ) ,
71 and to avoid possible mistakes.
72 This change however preserves
73 backwards compatibility with the old style of
74 .Nm
75 (i.e., tab characters only).
76 .Pp
77 The
78 .Em selectors
79 are encoded as a
80 .Em facility ,
81 a period
82 .Pq Dq \&. ,
83 an optional set of comparison flags
84 .Pq Oo \&! Oc Op <=> ,
85 and a
86 .Em level ,
87 with no intervening white-space.
88 Both the
89 .Em facility
90 and the
91 .Em level
92 are case insensitive.
93 .Pp
94 The
95 .Em facility
96 describes the part of the system generating the message, and is one of
97 the following keywords:
98 .Cm auth , authpriv , console , cron , daemon , ftp , kern , lpr ,
99 .Cm mail , mark , news , ntp , security , syslog , user , uucp ,
100 and
101 .Cm local0
102 through
103 .Cm local7 .
104 These keywords (with the exception of mark) correspond to
105 similar
106 .Dq Dv LOG_
107 values specified to the
108 .Xr openlog 3
109 and
110 .Xr syslog 3
111 library routines.
112 .Pp
113 The
114 .Em comparison flags
115 may be used to specify exactly what is logged.
116 The default comparison is
117 .Dq =>
118 (or, if you prefer,
119 .Dq >= ) ,
120 which means that messages from the specified
121 .Em facility
122 list, and of a priority
123 level equal to or greater than
124 .Em level
125 will be logged.
126 Comparison flags beginning with
127 .Dq Li \&!
128 will have their logical sense inverted.
129 Thus
130 .Dq !=info
131 means all levels except info and
132 .Dq !notice
133 has the same meaning as
134 .Dq <notice .
135 .Pp
136 The
137 .Em level
138 describes the severity of the message, and is a keyword from the
139 following ordered list (higher to lower):
140 .Cm emerg , crit , alert , err , warning , notice , info
141 and
142 .Cm debug .
143 These keywords correspond to
144 similar
145 .Dq Dv LOG_
146 values specified to the
147 .Xr syslog 3
148 library routine.
149 .Pp
150 Each block of lines is separated from the previous block by a
151 .Em program
152 or
153 .Em hostname
154 specification.
155 A block will only log messages corresponding to the most recent
156 .Em program
157 and
158 .Em hostname
159 specifications given.
160 Thus, with a block which selects
161 .Ql ppp
162 as the
163 .Em program ,
164 directly followed by a block that selects messages from the
165 .Em hostname
166 .Ql dialhost ,
167 the second block will only log messages
168 from the
169 .Xr ppp 8
170 program on dialhost.
171 .Pp
172 A
173 .Em program
174 specification is a line beginning with
175 .Ql #!prog
176 or
177 .Ql !prog
178 (the former is for compatibility with the previous syslogd, if one is sharing
179 .Nm
180 files, for example)
181 and the following blocks will be associated with calls to
182 .Xr syslog 3
183 from that specific program.
184 A
185 .Em program
186 specification for
187 .Ql foo
188 will also match any message logged by the kernel with the prefix
189 .Ql "foo: " .
190 The
191 .Ql #!+prog
192 or
193 .Ql !+prog
194 specification works just like the previous one,
195 and the
196 .Ql #!-prog
197 or
198 .Ql !-prog
199 specification will match any message but the ones from that
200 program.
201 Multiple programs may be listed, separated by commas:
202 .Ql !prog1,prog2
203 matches messages from either program, while
204 .Ql !-prog1,prog2
205 matches all messages but those from
206 .Ql prog1
207 or
208 .Ql prog2 .
209 .Pp
210 A
211 .Em hostname
212 specification of the form
213 .Ql #+hostname
214 or
215 .Ql +hostname
216 means the following blocks will be applied to messages
217 received from the specified hostname.
218 Alternatively, the
219 .Em hostname
220 specification
221 .Ql #-hostname
222 or
223 .Ql -hostname
224 causes the following blocks to be applied to messages
225 from any host but the one specified.
226 If the hostname is given as
227 .Ql @ ,
228 the local hostname will be used.
229 As for program specifications, multiple comma-separated
230 values may be specified for hostname specifications.
231 .Pp
232 A
233 .Em program
234 or
235 .Em hostname
236 specification may be reset by giving the program or hostname as
237 .Ql * .
238 .Pp
239 See
240 .Xr syslog 3
241 for further descriptions of both the
242 .Em facility
243 and
244 .Em level
245 keywords and their significance.
246 It is preferred that selections be made on
247 .Em facility
248 rather than
249 .Em program ,
250 since the latter can easily vary in a networked environment.
251 In some cases,
252 though, an appropriate
253 .Em facility
254 simply does not exist.
255 .Pp
256 If a received message matches the specified
257 .Em facility
258 and is of the specified
259 .Em level
260 .Em (or a higher level) ,
261 and the first word in the message after the date matches the
262 .Em program ,
263 the action specified in the
264 .Em action
265 field will be taken.
266 .Pp
267 Multiple
268 .Em selectors
269 may be specified for a single
270 .Em action
271 by separating them with semicolon
272 .Pq Dq \&;
273 characters.
274 It is important to note, however, that each
275 .Em selector
276 can modify the ones preceding it.
277 .Pp
278 Multiple
279 .Em facilities
280 may be specified for a single
281 .Em level
282 by separating them with comma
283 .Pq Dq \&,
284 characters.
285 .Pp
286 An asterisk
287 .Pq Dq *
288 can be used to specify all
289 .Em facilities ,
290 all
291 .Em levels ,
292 or all
293 .Em programs .
294 .Pp
295 The special
296 .Em facility
297 .Dq mark
298 receives a message at priority
299 .Dq info
300 every 20 minutes
301 (see
302 .Xr syslogd 8 ) .
303 This is not enabled by a
304 .Em facility
305 field containing an asterisk.
306 .Pp
307 The special
308 .Em level
309 .Dq none
310 disables a particular
311 .Em facility .
312 .Pp
313 The
314 .Em action
315 field of each line specifies the action to be taken when the
316 .Em selector
317 field selects a message.
318 There are five forms:
319 .Bl -bullet
320 .It
321 A pathname (beginning with a leading slash).
322 Selected messages are appended to the file.
323 .Pp
324 To ensure that kernel messages are written to disk promptly,
325 .Nm
326 calls
327 .Xr fsync 2
328 after writing messages from the kernel.
329 Other messages are not synced explicitly.
330 You may prefix a pathname with the minus sign,
331 .Dq - ,
332 to forego syncing the specified file after every kernel message.
333 Note that you might lose information if the system crashes
334 immediately following a write attempt.
335 Nevertheless, using the
336 .Dq -
337 option may improve performance,
338 especially if the kernel is logging many messages.
339 .It
340 A hostname (preceded by an at
341 .Pq Dq @
342 sign).
343 Selected messages are forwarded to the
344 .Xr syslogd 8
345 program on the named host.
346 If a port number is added after a colon
347 .Pq Ql :\&
348 then that port will be used as the destination port
349 rather than the usual syslog port.
350 IPv6 addresses can be used
351 by surrounding the address portion with
352 square brackets
353 .Po
354 .Ql [\&
355 and
356 .Ql ]\&
357 .Pc .
358 .It
359 A comma separated list of users.
360 Selected messages are written to those users
361 if they are logged in.
362 .It
363 An asterisk.
364 Selected messages are written to all logged-in users.
365 .It
366 A vertical bar
367 .Pq Dq \&| ,
368 followed by a command to pipe the selected
369 messages to.
370 The command is passed to
371 .Xr sh 1
372 for evaluation, so usual shell metacharacters or input/output
373 redirection can occur.
374 (Note however that redirecting
375 .Xr stdio 3
376 buffered output from the invoked command can cause additional delays,
377 or even lost output data in case a logging subprocess exited with a
378 signal.)
379 The command itself runs with
380 .Em stdout
381 and
382 .Em stderr
383 redirected to
384 .Pa /dev/null .
385 Upon receipt of a
386 .Dv SIGHUP ,
387 .Xr syslogd 8
388 will close the pipe to the process.
389 If the process did not exit
390 voluntarily, it will be sent a
391 .Dv SIGTERM
392 signal after a grace period of up to 60 seconds.
393 .Pp
394 The command will only be started once data arrives that should be piped
395 to it.
396 If it exited later, it will be restarted as necessary.
397 So if it
398 is desired that the subprocess should get exactly one line of input only
399 (which can be very resource-consuming if there are a lot of messages
400 flowing quickly), this can be achieved by exiting after just one line of
401 input.
402 If necessary, a script wrapper can be written to this effect.
403 .Pp
404 Unless the command is a full pipeline, it is probably useful to
405 start the command with
406 .Em exec
407 so that the invoking shell process does not wait for the command to
408 complete.
409 Warning: the process is started under the UID invoking
410 .Xr syslogd 8 ,
411 normally the superuser.
412 .El
413 .Pp
414 Blank lines and lines whose first non-blank character is a hash
415 .Pq Dq #
416 character are ignored.
417 If
418 .Ql #
419 is placed in the middle of the line, the
420 .Ql #
421 character and the rest of the line after it is ignored.
422 To prevent special meaning, the
423 .Ql #
424 character may be escaped with
425 .Ql \e ;
426 in this case preceding
427 .Ql \e
428 is removed and
429 .Ql #
430 is treated as an ordinary character.
431 .Sh IMPLEMENTATION NOTES
432 The
433 .Dq kern
434 facility is usually reserved for messages
435 generated by the local kernel.
436 Other messages logged with facility
437 .Dq kern
438 are usually translated to facility
439 .Dq user .
440 This translation can be disabled;
441 see
442 .Xr syslogd 8
443 for details.
444 .Sh FILES
445 .Bl -tag -width /etc/syslog.conf -compact
446 .It Pa /etc/syslog.conf
447 .Xr syslogd 8
448 configuration file
449 .El
450 .Sh EXAMPLES
451 A configuration file might appear as follows:
452 .Bd -literal
453 # Log all kernel messages, authentication messages of
454 # level notice or higher, and anything of level err or
455 # higher to the console.
456 # Don't log private authentication messages!
457 *.err;kern.*;auth.notice;authpriv.none;mail.crit        /dev/console
458
459 # Log anything (except mail) of level info or higher.
460 # Don't log private authentication messages!
461 *.info;mail.none;authpriv.none          /var/log/messages
462
463 # Log daemon messages at debug level only
464 daemon.=debug                                           /var/log/daemon.debug
465
466 # The authpriv file has restricted access.
467 authpriv.*                                              /var/log/secure
468
469 # Log all the mail messages in one place.
470 mail.*                                                  /var/log/maillog
471
472 # Everybody gets emergency messages, plus log them on another
473 # machine.
474 *.emerg                                                 *
475 *.emerg                                                 @arpa.berkeley.edu
476
477 # Root and Eric get alert and higher messages.
478 *.alert                                                 root,eric
479
480 # Save mail and news errors of level err and higher in a
481 # special file.
482 uucp,news.crit                                          /var/log/spoolerr
483
484 # Pipe all authentication messages to a filter.
485 auth.*                                  |exec /usr/local/sbin/authfilter
486
487 # Log all security messages to a separate file.
488 security.*                                              /var/log/security
489
490 # Log all writes to /dev/console to a separate file.
491 console.*                                               /var/log/console.log
492
493 # Save ftpd transactions along with mail and news
494 !ftpd
495 *.*                                                     /var/log/spoolerr
496
497 # Log ipfw messages without syncing after every message.
498 !ipfw
499 *.*                                                     -/var/log/ipfw
500 .Ed
501 .Sh SEE ALSO
502 .Xr syslog 3 ,
503 .Xr syslogd 8
504 .Sh BUGS
505 The effects of multiple
506 .Em selectors
507 are sometimes not intuitive.
508 For example
509 .Dq mail.crit,*.err
510 will select
511 .Dq mail
512 facility messages at the level of
513 .Dq err
514 or higher, not at the level of
515 .Dq crit
516 or higher.
517 .Pp
518 In networked environments, note that not all operating systems
519 implement the same set of facilities.
520 The facilities
521 authpriv, cron, ftp, and ntp that are known to this implementation
522 might be absent on the target system.
523 Even worse, DEC UNIX uses
524 facility number 10 (which is authpriv in this implementation) to
525 log events for their AdvFS file system.