xref: /freebsd/usr.sbin/syslogd/syslog.conf.5 (revision 8a7b61203704d362cfbc66c00619f51b24106b55)
1dea673e9SRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993
2dea673e9SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
3dea673e9SRodney W. Grimes.\"
4dea673e9SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
5dea673e9SRodney W. Grimes.\" modification, are permitted provided that the following conditions
6dea673e9SRodney W. Grimes.\" are met:
7dea673e9SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
8dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
9dea673e9SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
10dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
11dea673e9SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
13dea673e9SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
14dea673e9SRodney W. Grimes.\"    without specific prior written permission.
15dea673e9SRodney W. Grimes.\"
16dea673e9SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17dea673e9SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18dea673e9SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19dea673e9SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20dea673e9SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21dea673e9SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22dea673e9SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23dea673e9SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24dea673e9SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25dea673e9SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26dea673e9SRodney W. Grimes.\" SUCH DAMAGE.
27dea673e9SRodney W. Grimes.\"
2837d8e9a3SJohn-Mark Gurney.Dd December 10, 2020
29dea673e9SRodney W. Grimes.Dt SYSLOG.CONF 5
30dea673e9SRodney W. Grimes.Os
31dea673e9SRodney W. Grimes.Sh NAME
32dea673e9SRodney W. Grimes.Nm syslog.conf
33dea673e9SRodney W. Grimes.Nd
34dea673e9SRodney W. Grimes.Xr syslogd 8
35dea673e9SRodney W. Grimesconfiguration file
36dea673e9SRodney W. Grimes.Sh DESCRIPTION
37dea673e9SRodney W. GrimesThe
3824685462SJohn-Mark Gurney.Nm
39dea673e9SRodney W. Grimesfile is the configuration file for the
40dea673e9SRodney W. Grimes.Xr syslogd 8
41dea673e9SRodney W. Grimesprogram.
42f8c034f9SJordan K. HubbardIt consists of
43f8c034f9SJordan K. Hubbardblocks of lines separated by
447d367c51SAndrey V. Elsukov.Em program ,
45a144588dSDavid Malone.Em hostname
467d367c51SAndrey V. Elsukovor
477d367c51SAndrey V. Elsukov.Em property-based filter
48f47dba63SJulian Elischerspecifications (separations appear alone on their lines),
49f8c034f9SJordan K. Hubbardwith each line containing two fields: the
50dea673e9SRodney W. Grimes.Em selector
51dea673e9SRodney W. Grimesfield which specifies the types of messages and priorities to which the
52dea673e9SRodney W. Grimesline applies, and an
53dea673e9SRodney W. Grimes.Em action
54dea673e9SRodney W. Grimesfield which specifies the action to be taken if a message
55922a51eeSPhilippe Charnier.Xr syslogd 8
56dea673e9SRodney W. Grimesreceives matches the selection criteria.
57dea673e9SRodney W. GrimesThe
58dea673e9SRodney W. Grimes.Em selector
59dea673e9SRodney W. Grimesfield is separated from the
60dea673e9SRodney W. Grimes.Em action
6160159a06SJordan K. Hubbardfield by one or more tab characters or spaces.
6260159a06SJordan K. Hubbard.Pp
63fdec22c3SBaptiste DaroussinA special
64fdec22c3SBaptiste Daroussin.Em include
65fdec22c3SBaptiste Daroussinkeyword can be used to include all files with names ending in '.conf' and not
66fdec22c3SBaptiste Daroussinbeginning with a '.' contained in the directory following the keyword.
67fdec22c3SBaptiste DaroussinThis keyword can only be used in the first level configuration file.
68fdec22c3SBaptiste Daroussin.Pp
6960159a06SJordan K. HubbardNote that if you use spaces as separators, your
707ae71655SCrist J. Clark.Nm
7160159a06SJordan K. Hubbardmight be incompatible with other Unices or Unix-like systems.
726b010ec6STom RhodesThis functionality was added for ease of configuration
7337d8e9a3SJohn-Mark Gurney(e.g.,\& it is possible to cut-and-paste into
747ae71655SCrist J. Clark.Nm ) ,
75f2e366a1SSheldon Hearnand to avoid possible mistakes.
76f2e366a1SSheldon HearnThis change however preserves
776b010ec6STom Rhodesbackwards compatibility with the old style of
787ae71655SCrist J. Clark.Nm
7907bfccd7SRuslan Ermilov(i.e., tab characters only).
80dea673e9SRodney W. Grimes.Pp
81dea673e9SRodney W. GrimesThe
827ae71655SCrist J. Clark.Em selectors
83dea673e9SRodney W. Grimesare encoded as a
84dea673e9SRodney W. Grimes.Em facility ,
8524685462SJohn-Mark Gurneya period
8624685462SJohn-Mark Gurney.Pq Dq \&. ,
872eec1ab0SPoul-Henning Kampan optional set of comparison flags
88c041c1e0SRuslan Ermilov.Pq Oo \&! Oc Op <=> ,
8924685462SJohn-Mark Gurneyand a
90dea673e9SRodney W. Grimes.Em level ,
91dea673e9SRodney W. Grimeswith no intervening white-space.
92dea673e9SRodney W. GrimesBoth the
93dea673e9SRodney W. Grimes.Em facility
94dea673e9SRodney W. Grimesand the
95dea673e9SRodney W. Grimes.Em level
96dea673e9SRodney W. Grimesare case insensitive.
97dea673e9SRodney W. Grimes.Pp
98dea673e9SRodney W. GrimesThe
99dea673e9SRodney W. Grimes.Em facility
100dea673e9SRodney W. Grimesdescribes the part of the system generating the message, and is one of
10142c3aae2STom Rhodesthe following keywords:
10242c3aae2STom Rhodes.Cm auth , authpriv , console , cron , daemon , ftp , kern , lpr ,
10342c3aae2STom Rhodes.Cm mail , mark , news , ntp , security , syslog , user , uucp ,
10442c3aae2STom Rhodesand
10542c3aae2STom Rhodes.Cm local0
10642c3aae2STom Rhodesthrough
10742c3aae2STom Rhodes.Cm local7 .
1086b010ec6STom RhodesThese keywords (with the exception of mark) correspond to
109dea673e9SRodney W. Grimessimilar
110dea673e9SRodney W. Grimes.Dq Dv LOG_
111dea673e9SRodney W. Grimesvalues specified to the
112dea673e9SRodney W. Grimes.Xr openlog 3
113dea673e9SRodney W. Grimesand
114dea673e9SRodney W. Grimes.Xr syslog 3
115dea673e9SRodney W. Grimeslibrary routines.
116dea673e9SRodney W. Grimes.Pp
117dea673e9SRodney W. GrimesThe
1182eec1ab0SPoul-Henning Kamp.Em comparison flags
1192eec1ab0SPoul-Henning Kampmay be used to specify exactly what is logged.
1206b010ec6STom RhodesThe default comparison is
1212eec1ab0SPoul-Henning Kamp.Dq =>
1222eec1ab0SPoul-Henning Kamp(or, if you prefer,
123610a5778SRuslan Ermilov.Dq >= ) ,
1242eec1ab0SPoul-Henning Kampwhich means that messages from the specified
1252eec1ab0SPoul-Henning Kamp.Em facility
1266b010ec6STom Rhodeslist, and of a priority
1276b010ec6STom Rhodeslevel equal to or greater than
1282eec1ab0SPoul-Henning Kamp.Em level
1292eec1ab0SPoul-Henning Kampwill be logged.
130ef21d92fSDavid MaloneComparison flags beginning with
131c041c1e0SRuslan Ermilov.Dq Li \&!
132ef21d92fSDavid Malonewill have their logical sense inverted.
133ef21d92fSDavid MaloneThus
134ef21d92fSDavid Malone.Dq !=info
135ef21d92fSDavid Malonemeans all levels except info and
136ef21d92fSDavid Malone.Dq !notice
137ef21d92fSDavid Malonehas the same meaning as
138ef21d92fSDavid Malone.Dq <notice .
1392eec1ab0SPoul-Henning Kamp.Pp
1402eec1ab0SPoul-Henning KampThe
141dea673e9SRodney W. Grimes.Em level
142dea673e9SRodney W. Grimesdescribes the severity of the message, and is a keyword from the
14342c3aae2STom Rhodesfollowing ordered list (higher to lower):
144*86781401SFelix Guest.Cm emerg , alert , crit , err , warning , notice , info
14542c3aae2STom Rhodesand
14642c3aae2STom Rhodes.Cm debug .
1476b010ec6STom RhodesThese keywords correspond to
148dea673e9SRodney W. Grimessimilar
14924685462SJohn-Mark Gurney.Dq Dv LOG_
150dea673e9SRodney W. Grimesvalues specified to the
151922a51eeSPhilippe Charnier.Xr syslog 3
152dea673e9SRodney W. Grimeslibrary routine.
153dea673e9SRodney W. Grimes.Pp
154a144588dSDavid MaloneEach block of lines is separated from the previous block by a
1557d367c51SAndrey V. Elsukov.Em program ,
156a144588dSDavid Malone.Em hostname
1577d367c51SAndrey V. Elsukovor
1587d367c51SAndrey V. Elsukov.Em property-based filter
159a144588dSDavid Malonespecification.
160a144588dSDavid MaloneA block will only log messages corresponding to the most recent
1617d367c51SAndrey V. Elsukov.Em program ,
162a144588dSDavid Malone.Em hostname
1637d367c51SAndrey V. Elsukovand
1647d367c51SAndrey V. Elsukov.Em property-based filter
165a144588dSDavid Malonespecifications given.
1666b010ec6STom RhodesThus, with a block which selects
167a144588dSDavid Malone.Ql ppp
168a144588dSDavid Maloneas the
169a144588dSDavid Malone.Em program ,
170a144588dSDavid Malonedirectly followed by a block that selects messages from the
171a144588dSDavid Malone.Em hostname
172a144588dSDavid Malone.Ql dialhost ,
1736b010ec6STom Rhodesthe second block will only log messages
174a144588dSDavid Malonefrom the
175a144588dSDavid Malone.Xr ppp 8
176a144588dSDavid Maloneprogram on dialhost.
177a144588dSDavid Malone.Pp
178a144588dSDavid MaloneA
179a144588dSDavid Malone.Em program
180a144588dSDavid Malonespecification is a line beginning with
181a144588dSDavid Malone.Ql #!prog
182a144588dSDavid Maloneor
183a144588dSDavid Malone.Ql !prog
184f8c034f9SJordan K. Hubbard(the former is for compatibility with the previous syslogd, if one is sharing
1857ae71655SCrist J. Clark.Nm
186922a51eeSPhilippe Charnierfiles, for example)
187a144588dSDavid Maloneand the following blocks will be associated with calls to
188a144588dSDavid Malone.Xr syslog 3
189a144588dSDavid Malonefrom that specific program.
190a144588dSDavid MaloneA
191a144588dSDavid Malone.Em program
192a144588dSDavid Malonespecification for
193a144588dSDavid Malone.Ql foo
194a144588dSDavid Malonewill also match any message logged by the kernel with the prefix
195a144588dSDavid Malone.Ql "foo: " .
196f50b861cSDaniel C. SobralThe
197f50b861cSDaniel C. Sobral.Ql #!+prog
198f50b861cSDaniel C. Sobralor
199f50b861cSDaniel C. Sobral.Ql !+prog
200f50b861cSDaniel C. Sobralspecification works just like the previous one,
201f50b861cSDaniel C. Sobraland the
202f50b861cSDaniel C. Sobral.Ql #!-prog
203f50b861cSDaniel C. Sobralor
204f50b861cSDaniel C. Sobral.Ql !-prog
205f50b861cSDaniel C. Sobralspecification will match any message but the ones from that
206f50b861cSDaniel C. Sobralprogram.
2077ac1f02eSThomas QuinotMultiple programs may be listed, separated by commas:
2087ac1f02eSThomas Quinot.Ql !prog1,prog2
2097ac1f02eSThomas Quinotmatches messages from either program, while
2107ac1f02eSThomas Quinot.Ql !-prog1,prog2
2117ac1f02eSThomas Quinotmatches all messages but those from
2127ac1f02eSThomas Quinot.Ql prog1
2137ac1f02eSThomas Quinotor
2147ac1f02eSThomas Quinot.Ql prog2 .
2157ac1f02eSThomas Quinot.Pp
216a144588dSDavid MaloneA
217a144588dSDavid Malone.Em hostname
218a144588dSDavid Malonespecification of the form
219a144588dSDavid Malone.Ql #+hostname
220a144588dSDavid Maloneor
221a144588dSDavid Malone.Ql +hostname
2226b010ec6STom Rhodesmeans the following blocks will be applied to messages
223a144588dSDavid Malonereceived from the specified hostname.
2246b010ec6STom RhodesAlternatively, the
225a144588dSDavid Malone.Em hostname
226a144588dSDavid Malonespecification
227a144588dSDavid Malone.Ql #-hostname
228a144588dSDavid Maloneor
229a144588dSDavid Malone.Ql -hostname
230a144588dSDavid Malonecauses the following blocks to be applied to messages
231a144588dSDavid Malonefrom any host but the one specified.
232a144588dSDavid MaloneIf the hostname is given as
233a144588dSDavid Malone.Ql @ ,
234a144588dSDavid Malonethe local hostname will be used.
2356fb9b618SGiorgos KeramidasAs for program specifications, multiple comma-separated
2367ac1f02eSThomas Quinotvalues may be specified for hostname specifications.
2377ac1f02eSThomas Quinot.Pp
238a144588dSDavid MaloneA
2397d367c51SAndrey V. Elsukov.Em property-based filter
2407d367c51SAndrey V. Elsukovspecification is a line beginning with
2417d367c51SAndrey V. Elsukov.Ql #:
242a144588dSDavid Maloneor
2437d367c51SAndrey V. Elsukov.Ql \&:
2447d367c51SAndrey V. Elsukovand the following blocks will be applied only when filter value
245cbf54131SGordon Berglingmatches given filter propertie's value.
246cbf54131SGordon BerglingSee
2477d367c51SAndrey V. Elsukov.Sx PROPERTY-BASED FILTERS
2487d367c51SAndrey V. Elsukovsection for more details.
2497d367c51SAndrey V. Elsukov.Pp
2507d367c51SAndrey V. ElsukovA
2517d367c51SAndrey V. Elsukov.Em program ,
252a144588dSDavid Malone.Em hostname
2537d367c51SAndrey V. Elsukovor
2547d367c51SAndrey V. Elsukov.Em property-based filter
2557d367c51SAndrey V. Elsukovspecification may be reset by giving
2567d367c51SAndrey V. Elsukov.Ql *
2577d367c51SAndrey V. Elsukovas an argument.
258f8c034f9SJordan K. Hubbard.Pp
259dea673e9SRodney W. GrimesSee
260dea673e9SRodney W. Grimes.Xr syslog 3
2616b010ec6STom Rhodesfor further descriptions of both the
262dea673e9SRodney W. Grimes.Em facility
263dea673e9SRodney W. Grimesand
264dea673e9SRodney W. Grimes.Em level
265f2e366a1SSheldon Hearnkeywords and their significance.
26636a142c4SRuslan ErmilovIt is preferred that selections be made on
267f8c034f9SJordan K. Hubbard.Em facility
268f8c034f9SJordan K. Hubbardrather than
269f8c034f9SJordan K. Hubbard.Em program ,
270f2e366a1SSheldon Hearnsince the latter can easily vary in a networked environment.
271f2e366a1SSheldon HearnIn some cases,
272f8c034f9SJordan K. Hubbardthough, an appropriate
273f8c034f9SJordan K. Hubbard.Em facility
2740227791bSRuslan Ermilovsimply does not exist.
275dea673e9SRodney W. Grimes.Pp
276dea673e9SRodney W. GrimesIf a received message matches the specified
277dea673e9SRodney W. Grimes.Em facility
278dea673e9SRodney W. Grimesand is of the specified
279dea673e9SRodney W. Grimes.Em level
280dea673e9SRodney W. Grimes.Em (or a higher level) ,
281f8c034f9SJordan K. Hubbardand the first word in the message after the date matches the
282f8c034f9SJordan K. Hubbard.Em program ,
283dea673e9SRodney W. Grimesthe action specified in the
284dea673e9SRodney W. Grimes.Em action
285dea673e9SRodney W. Grimesfield will be taken.
286dea673e9SRodney W. Grimes.Pp
287dea673e9SRodney W. GrimesMultiple
288dea673e9SRodney W. Grimes.Em selectors
289dea673e9SRodney W. Grimesmay be specified for a single
290dea673e9SRodney W. Grimes.Em action
29124685462SJohn-Mark Gurneyby separating them with semicolon
29224685462SJohn-Mark Gurney.Pq Dq \&;
29324685462SJohn-Mark Gurneycharacters.
294dea673e9SRodney W. GrimesIt is important to note, however, that each
295dea673e9SRodney W. Grimes.Em selector
296dea673e9SRodney W. Grimescan modify the ones preceding it.
297dea673e9SRodney W. Grimes.Pp
298dea673e9SRodney W. GrimesMultiple
299dea673e9SRodney W. Grimes.Em facilities
300dea673e9SRodney W. Grimesmay be specified for a single
301dea673e9SRodney W. Grimes.Em level
30224685462SJohn-Mark Gurneyby separating them with comma
30324685462SJohn-Mark Gurney.Pq Dq \&,
30424685462SJohn-Mark Gurneycharacters.
305dea673e9SRodney W. Grimes.Pp
30624685462SJohn-Mark GurneyAn asterisk
30724685462SJohn-Mark Gurney.Pq Dq *
30824685462SJohn-Mark Gurneycan be used to specify all
3096b010ec6STom Rhodes.Em facilities ,
310f8c034f9SJordan K. Hubbardall
3116b010ec6STom Rhodes.Em levels ,
312dea673e9SRodney W. Grimesor all
313f8c034f9SJordan K. Hubbard.Em programs .
314dea673e9SRodney W. Grimes.Pp
315dea673e9SRodney W. GrimesThe special
316dea673e9SRodney W. Grimes.Em facility
31724685462SJohn-Mark Gurney.Dq mark
31824685462SJohn-Mark Gurneyreceives a message at priority
31924685462SJohn-Mark Gurney.Dq info
32024685462SJohn-Mark Gurneyevery 20 minutes
321dea673e9SRodney W. Grimes(see
322dea673e9SRodney W. Grimes.Xr syslogd 8 ) .
323dea673e9SRodney W. GrimesThis is not enabled by a
324dea673e9SRodney W. Grimes.Em facility
325dea673e9SRodney W. Grimesfield containing an asterisk.
326dea673e9SRodney W. Grimes.Pp
327dea673e9SRodney W. GrimesThe special
328dea673e9SRodney W. Grimes.Em level
32924685462SJohn-Mark Gurney.Dq none
33024685462SJohn-Mark Gurneydisables a particular
331dea673e9SRodney W. Grimes.Em facility .
332dea673e9SRodney W. Grimes.Pp
333dea673e9SRodney W. GrimesThe
334dea673e9SRodney W. Grimes.Em action
335dea673e9SRodney W. Grimesfield of each line specifies the action to be taken when the
336dea673e9SRodney W. Grimes.Em selector
337dea673e9SRodney W. Grimesfield selects a message.
3385fadfc4cSJoerg WunschThere are five forms:
339dea673e9SRodney W. Grimes.Bl -bullet
340dea673e9SRodney W. Grimes.It
341dea673e9SRodney W. GrimesA pathname (beginning with a leading slash).
342dea673e9SRodney W. GrimesSelected messages are appended to the file.
3430f2ffc4eSDavid Malone.Pp
3440f2ffc4eSDavid MaloneTo ensure that kernel messages are written to disk promptly,
3450f2ffc4eSDavid Malone.Nm
3460f2ffc4eSDavid Malonecalls
3470f2ffc4eSDavid Malone.Xr fsync 2
3480f2ffc4eSDavid Maloneafter writing messages from the kernel.
3490f2ffc4eSDavid MaloneOther messages are not synced explicitly.
3500f2ffc4eSDavid MaloneYou may prefix a pathname with the minus sign,
3510f2ffc4eSDavid Malone.Dq - ,
3520f2ffc4eSDavid Maloneto forego syncing the specified file after every kernel message.
3530f2ffc4eSDavid MaloneNote that you might lose information if the system crashes
3540f2ffc4eSDavid Maloneimmediately following a write attempt.
3550f2ffc4eSDavid MaloneNevertheless, using the
3560f2ffc4eSDavid Malone.Dq -
3570f2ffc4eSDavid Maloneoption may improve performance,
3580f2ffc4eSDavid Maloneespecially if the kernel is logging many messages.
359dea673e9SRodney W. Grimes.It
36024685462SJohn-Mark GurneyA hostname (preceded by an at
36124685462SJohn-Mark Gurney.Pq Dq @
36224685462SJohn-Mark Gurneysign).
363dea673e9SRodney W. GrimesSelected messages are forwarded to the
364922a51eeSPhilippe Charnier.Xr syslogd 8
365dea673e9SRodney W. Grimesprogram on the named host.
366be389c75SJulian ElischerIf a port number is added after a colon
367bc84aa4bSRuslan Ermilov.Pq Ql :\&
368bc84aa4bSRuslan Ermilovthen that port will be used as the destination port
369bc84aa4bSRuslan Ermilovrather than the usual syslog port.
370b5bec591SEitan AdlerIPv6 addresses can be used
371b5bec591SEitan Adlerby surrounding the address portion with
372b5bec591SEitan Adlersquare brackets
373b5bec591SEitan Adler.Po
374b5bec591SEitan Adler.Ql [\&
375b5bec591SEitan Adlerand
376b5bec591SEitan Adler.Ql ]\&
377b5bec591SEitan Adler.Pc .
378dea673e9SRodney W. Grimes.It
379dea673e9SRodney W. GrimesA comma separated list of users.
380dea673e9SRodney W. GrimesSelected messages are written to those users
381dea673e9SRodney W. Grimesif they are logged in.
382dea673e9SRodney W. Grimes.It
383dea673e9SRodney W. GrimesAn asterisk.
384dea673e9SRodney W. GrimesSelected messages are written to all logged-in users.
3855fadfc4cSJoerg Wunsch.It
38624685462SJohn-Mark GurneyA vertical bar
38724685462SJohn-Mark Gurney.Pq Dq \&| ,
38824685462SJohn-Mark Gurneyfollowed by a command to pipe the selected
38907bfccd7SRuslan Ermilovmessages to.
39007bfccd7SRuslan ErmilovThe command is passed to
3917ae71655SCrist J. Clark.Xr sh 1
3925fadfc4cSJoerg Wunschfor evaluation, so usual shell metacharacters or input/output
39307bfccd7SRuslan Ermilovredirection can occur.
39407bfccd7SRuslan Ermilov(Note however that redirecting
3955fadfc4cSJoerg Wunsch.Xr stdio 3
3965fadfc4cSJoerg Wunschbuffered output from the invoked command can cause additional delays,
3975fadfc4cSJoerg Wunschor even lost output data in case a logging subprocess exited with a
398455fb174SRuslan Ermilovsignal.)
399455fb174SRuslan ErmilovThe command itself runs with
4005fadfc4cSJoerg Wunsch.Em stdout
4015fadfc4cSJoerg Wunschand
4025fadfc4cSJoerg Wunsch.Em stderr
4035fadfc4cSJoerg Wunschredirected to
4045fadfc4cSJoerg Wunsch.Pa /dev/null .
4055fadfc4cSJoerg WunschUpon receipt of a
4065fadfc4cSJoerg Wunsch.Dv SIGHUP ,
4077ae71655SCrist J. Clark.Xr syslogd 8
40807bfccd7SRuslan Ermilovwill close the pipe to the process.
4090227791bSRuslan ErmilovIf the process did not exit
4107fa793ccSMike Pritchardvoluntarily, it will be sent a
4115fadfc4cSJoerg Wunsch.Dv SIGTERM
41281be6c75SJoerg Wunschsignal after a grace period of up to 60 seconds.
4135fadfc4cSJoerg Wunsch.Pp
4147fa793ccSMike PritchardThe command will only be started once data arrives that should be piped
41507bfccd7SRuslan Ermilovto it.
41607bfccd7SRuslan ErmilovIf it exited later, it will be restarted as necessary.
41707bfccd7SRuslan ErmilovSo if it
41881be6c75SJoerg Wunschis desired that the subprocess should get exactly one line of input only
41981be6c75SJoerg Wunsch(which can be very resource-consuming if there are a lot of messages
42081be6c75SJoerg Wunschflowing quickly), this can be achieved by exiting after just one line of
42107bfccd7SRuslan Ermilovinput.
42207bfccd7SRuslan ErmilovIf necessary, a script wrapper can be written to this effect.
4235fadfc4cSJoerg Wunsch.Pp
42436a142c4SRuslan ErmilovUnless the command is a full pipeline, it is probably useful to
4255fadfc4cSJoerg Wunschstart the command with
4265fadfc4cSJoerg Wunsch.Em exec
4275fadfc4cSJoerg Wunschso that the invoking shell process does not wait for the command to
42807bfccd7SRuslan Ermilovcomplete.
42907bfccd7SRuslan ErmilovWarning: the process is started under the UID invoking
4305fadfc4cSJoerg Wunsch.Xr syslogd 8 ,
4317fa793ccSMike Pritchardnormally the superuser.
432dea673e9SRodney W. Grimes.El
433dea673e9SRodney W. Grimes.Pp
43424685462SJohn-Mark GurneyBlank lines and lines whose first non-blank character is a hash
43524685462SJohn-Mark Gurney.Pq Dq #
436dea673e9SRodney W. Grimescharacter are ignored.
4377e1535c5SMaxim SobolevIf
4387e1535c5SMaxim Sobolev.Ql #
4397e1535c5SMaxim Sobolevis placed in the middle of the line, the
4407e1535c5SMaxim Sobolev.Ql #
4417e1535c5SMaxim Sobolevcharacter and the rest of the line after it is ignored.
4427e1535c5SMaxim SobolevTo prevent special meaning, the
4437e1535c5SMaxim Sobolev.Ql #
4447e1535c5SMaxim Sobolevcharacter may be escaped with
4457e1535c5SMaxim Sobolev.Ql \e ;
4467e1535c5SMaxim Sobolevin this case preceding
4477e1535c5SMaxim Sobolev.Ql \e
4487e1535c5SMaxim Sobolevis removed and
4497e1535c5SMaxim Sobolev.Ql #
4507e1535c5SMaxim Sobolevis treated as an ordinary character.
4517d367c51SAndrey V. Elsukov.Sh PROPERTY-BASED FILTERS
4527d367c51SAndrey V. Elsukov.Em program ,
4537d367c51SAndrey V. Elsukov.Em hostname
4547d367c51SAndrey V. Elsukovspecifications performs exact match filtering against explicit field only.
4557d367c51SAndrey V. Elsukov.Em Property-based filters
4567d367c51SAndrey V. Elsukovfeature substring and regular expressions (see
4577d367c51SAndrey V. Elsukov.Xr re_format 7 )
4587d367c51SAndrey V. Elsukovmatching against various message attributes.
4597d367c51SAndrey V. ElsukovFilter specification starts with
4607d367c51SAndrey V. Elsukov.Ql #:
4617d367c51SAndrey V. Elsukovor
4627d367c51SAndrey V. Elsukov.Ql \&:
4637d367c51SAndrey V. Elsukovfollowed by three comma-separated fields
4647d367c51SAndrey V. Elsukov.Em property , operator , \&"value\&" .
465cbf54131SGordon BerglingValue must be double-quoted.
466cbf54131SGordon BerglingA double quote and backslash must be escaped by a backslash.
4677d367c51SAndrey V. Elsukov.Pp
4687d367c51SAndrey V. ElsukovFollowing
4697d367c51SAndrey V. Elsukov.Em properties
4707d367c51SAndrey V. Elsukovare supported as test value:
4717d367c51SAndrey V. Elsukov.Pp
4727d367c51SAndrey V. Elsukov.Bl -bullet -compact
4737d367c51SAndrey V. Elsukov.It
4747d367c51SAndrey V. Elsukov.Ql msg
4757d367c51SAndrey V. Elsukov- body of the message received.
4767d367c51SAndrey V. Elsukov.It
4777d367c51SAndrey V. Elsukov.Ql programname
4787d367c51SAndrey V. Elsukov- program name sent the message
4797d367c51SAndrey V. Elsukov.It
4807d367c51SAndrey V. Elsukov.Ql hostname
4817d367c51SAndrey V. Elsukov- hostname of message's originator
4827d367c51SAndrey V. Elsukov.It
4837d367c51SAndrey V. Elsukov.Ql source
4847d367c51SAndrey V. Elsukov- an alias for hostname
4857d367c51SAndrey V. Elsukov.El
4867d367c51SAndrey V. Elsukov.Pp
4877d367c51SAndrey V. ElsukovOperator specifies a comparison function between
4887d367c51SAndrey V. Elsukov.Em propertie's
4897d367c51SAndrey V. Elsukov value against filter's value.
4907d367c51SAndrey V. ElsukovPossible operators:
4917d367c51SAndrey V. Elsukov.Pp
4927d367c51SAndrey V. Elsukov.Bl -bullet -compact
4937d367c51SAndrey V. Elsukov.It
4947d367c51SAndrey V. Elsukov.Ql contains
4957d367c51SAndrey V. Elsukov- true if filter value is found as a substring of
4967d367c51SAndrey V. Elsukov.Em property
4977d367c51SAndrey V. Elsukov.It
4987d367c51SAndrey V. Elsukov.Ql isequal
4997d367c51SAndrey V. Elsukov- true if filter value is equal to
5007d367c51SAndrey V. Elsukov.Em property
5017d367c51SAndrey V. Elsukov.It
5027d367c51SAndrey V. Elsukov.Ql startswith
5037d367c51SAndrey V. Elsukov- true if property starts with filter value
5047d367c51SAndrey V. Elsukov.It
5057d367c51SAndrey V. Elsukov.Ql regex
5067d367c51SAndrey V. Elsukov- true if property matches basic regular expression defined in filter value
5077d367c51SAndrey V. Elsukov.It
5087d367c51SAndrey V. Elsukov.Ql ereregex
5097d367c51SAndrey V. Elsukov- true if property matches extended regular expression defined in filter value
5107d367c51SAndrey V. Elsukov.El
5117d367c51SAndrey V. Elsukov.Pp
5127d367c51SAndrey V. ElsukovOperator may be prefixed by
5137d367c51SAndrey V. Elsukov.Pp
5147d367c51SAndrey V. Elsukov.Bl -bullet -compact
5157d367c51SAndrey V. Elsukov.It
5167d367c51SAndrey V. Elsukov.Ql \&!
5177d367c51SAndrey V. Elsukov- to invert compare logic
5187d367c51SAndrey V. Elsukov.It
5197d367c51SAndrey V. Elsukov.Ql icase_
5207d367c51SAndrey V. Elsukov- to make comparison function case insensitive
5217d367c51SAndrey V. Elsukov.El
52259a3c79dSRuslan Ermilov.Sh IMPLEMENTATION NOTES
52359a3c79dSRuslan ErmilovThe
52459a3c79dSRuslan Ermilov.Dq kern
52559a3c79dSRuslan Ermilovfacility is usually reserved for messages
52659a3c79dSRuslan Ermilovgenerated by the local kernel.
52759a3c79dSRuslan ErmilovOther messages logged with facility
52859a3c79dSRuslan Ermilov.Dq kern
52959a3c79dSRuslan Ermilovare usually translated to facility
53059a3c79dSRuslan Ermilov.Dq user .
53159a3c79dSRuslan ErmilovThis translation can be disabled;
53259a3c79dSRuslan Ermilovsee
53359a3c79dSRuslan Ermilov.Xr syslogd 8
53459a3c79dSRuslan Ermilovfor details.
53559a3c79dSRuslan Ermilov.Sh FILES
53659a3c79dSRuslan Ermilov.Bl -tag -width /etc/syslog.conf -compact
53759a3c79dSRuslan Ermilov.It Pa /etc/syslog.conf
53859a3c79dSRuslan Ermilov.Xr syslogd 8
53959a3c79dSRuslan Ermilovconfiguration file
54059a3c79dSRuslan Ermilov.El
541dea673e9SRodney W. Grimes.Sh EXAMPLES
542dea673e9SRodney W. GrimesA configuration file might appear as follows:
543dea673e9SRodney W. Grimes.Bd -literal
544dea673e9SRodney W. Grimes# Log all kernel messages, authentication messages of
5456b010ec6STom Rhodes# level notice or higher, and anything of level err or
546dea673e9SRodney W. Grimes# higher to the console.
54737d8e9a3SJohn-Mark Gurney# Do not log private authentication messages!
5485b34e708STom Rhodes*.err;kern.*;auth.notice;authpriv.none;mail.crit	/dev/console
549dea673e9SRodney W. Grimes
550dea673e9SRodney W. Grimes# Log anything (except mail) of level info or higher.
55137d8e9a3SJohn-Mark Gurney# Do not log private authentication messages!
552dea673e9SRodney W. Grimes*.info;mail.none;authpriv.none		/var/log/messages
553dea673e9SRodney W. Grimes
5542eec1ab0SPoul-Henning Kamp# Log daemon messages at debug level only
5552eec1ab0SPoul-Henning Kampdaemon.=debug						/var/log/daemon.debug
5562eec1ab0SPoul-Henning Kamp
557dea673e9SRodney W. Grimes# The authpriv file has restricted access.
558dea673e9SRodney W. Grimesauthpriv.*						/var/log/secure
559dea673e9SRodney W. Grimes
560dea673e9SRodney W. Grimes# Log all the mail messages in one place.
561dea673e9SRodney W. Grimesmail.*							/var/log/maillog
562dea673e9SRodney W. Grimes
563dea673e9SRodney W. Grimes# Everybody gets emergency messages, plus log them on another
564dea673e9SRodney W. Grimes# machine.
565dea673e9SRodney W. Grimes*.emerg							*
566dea673e9SRodney W. Grimes*.emerg							@arpa.berkeley.edu
567dea673e9SRodney W. Grimes
568dea673e9SRodney W. Grimes# Root and Eric get alert and higher messages.
569dea673e9SRodney W. Grimes*.alert							root,eric
570dea673e9SRodney W. Grimes
571dea673e9SRodney W. Grimes# Save mail and news errors of level err and higher in a
572dea673e9SRodney W. Grimes# special file.
573dea673e9SRodney W. Grimesuucp,news.crit						/var/log/spoolerr
574f8c034f9SJordan K. Hubbard
5755fadfc4cSJoerg Wunsch# Pipe all authentication messages to a filter.
5765fadfc4cSJoerg Wunschauth.*					|exec /usr/local/sbin/authfilter
5775fadfc4cSJoerg Wunsch
578fa62586aSBrian Feldman# Log all security messages to a separate file.
579fa62586aSBrian Feldmansecurity.*						/var/log/security
5805c620e2dSChris Timmons
5815c620e2dSChris Timmons# Log all writes to /dev/console to a separate file.
5825c620e2dSChris Timmonsconsole.*						/var/log/console.log
5830f2ffc4eSDavid Malone
5845cd1d3ffSAndriy Gapon# Save ftpd transactions along with mail and news
5855cd1d3ffSAndriy Gapon!ftpd
5865cd1d3ffSAndriy Gapon*.*							/var/log/spoolerr
5875cd1d3ffSAndriy Gapon
5880f2ffc4eSDavid Malone# Log ipfw messages without syncing after every message.
5890f2ffc4eSDavid Malone!ipfw
5900f2ffc4eSDavid Malone*.*							-/var/log/ipfw
5917d367c51SAndrey V. Elsukov
5927d367c51SAndrey V. Elsukov# Log ipfw messages with "Deny" in the message body.
5937d367c51SAndrey V. Elsukov:msg, contains, ".*Deny.*"
5947d367c51SAndrey V. Elsukov*.*							/var/log/ipfw.deny
5957d367c51SAndrey V. Elsukov
5967d367c51SAndrey V. Elsukov# Reset program name filtering
5977d367c51SAndrey V. Elsukov!*
5987d367c51SAndrey V. Elsukov
5997d367c51SAndrey V. Elsukov# Log messages from bird or bird6 into one file
60037d8e9a3SJohn-Mark Gurney:programname, regex, "^bird6?$"
6017d367c51SAndrey V. Elsukov*.*							/var/log/bird-all.log
6027d367c51SAndrey V. Elsukov
6037d367c51SAndrey V. Elsukov# Log messages from servers in racks 10-19 in multiple locations, case insensitive
6047d367c51SAndrey V. Elsukov:hostname, icase_ereregex, "^server-(dcA|podB|cdn)-rack1[0-9]{2}\\..*"
6057d367c51SAndrey V. Elsukov*.*							/var/log/racks10..19.log
606dea673e9SRodney W. Grimes.Ed
60759a3c79dSRuslan Ermilov.Sh SEE ALSO
60859a3c79dSRuslan Ermilov.Xr syslog 3 ,
609481a1902SDavid Malone.Xr syslogd 8
610dea673e9SRodney W. Grimes.Sh BUGS
611922a51eeSPhilippe CharnierThe effects of multiple
612922a51eeSPhilippe Charnier.Em selectors
613922a51eeSPhilippe Charnierare sometimes not intuitive.
61424685462SJohn-Mark GurneyFor example
61524685462SJohn-Mark Gurney.Dq mail.crit,*.err
61624685462SJohn-Mark Gurneywill select
61724685462SJohn-Mark Gurney.Dq mail
61824685462SJohn-Mark Gurneyfacility messages at the level of
61924685462SJohn-Mark Gurney.Dq err
62024685462SJohn-Mark Gurneyor higher, not at the level of
62124685462SJohn-Mark Gurney.Dq crit
62224685462SJohn-Mark Gurneyor higher.
623605efc87SJoerg Wunsch.Pp
624605efc87SJoerg WunschIn networked environments, note that not all operating systems
62507bfccd7SRuslan Ermilovimplement the same set of facilities.
62607bfccd7SRuslan ErmilovThe facilities
627605efc87SJoerg Wunschauthpriv, cron, ftp, and ntp that are known to this implementation
62807bfccd7SRuslan Ermilovmight be absent on the target system.
62907bfccd7SRuslan ErmilovEven worse, DEC UNIX uses
630605efc87SJoerg Wunschfacility number 10 (which is authpriv in this implementation) to
631605efc87SJoerg Wunschlog events for their AdvFS file system.
632