xref: /freebsd/usr.sbin/newsyslog/newsyslog.conf.5 (revision 094517119c62c23369d545a7475ae982d86330a3)
1.\" This file was split from the newsyslog(8) manual page by Tom Rhodes
2.\" and includes modifications as appropriate.
3.\" The original header is included below:
4.\"
5.\" This file contains changes from the Open Software Foundation.
6.\"
7.\"     from: @(#)newsyslog.8
8.\" $FreeBSD$
9.\"
10.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
11.\"
12.\" Permission to use, copy, modify, and distribute this software
13.\" and its documentation for any purpose and without fee is
14.\" hereby granted, provided that the above copyright notice
15.\" appear in all copies and that both that copyright notice and
16.\" this permission notice appear in supporting documentation,
17.\" and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
18.\" used in advertising or publicity pertaining to distribution
19.\" of the software without specific, written prior permission.
20.\" M.I.T. and the M.I.T. S.I.P.B. make no representations about
21.\" the suitability of this software for any purpose.  It is
22.\" provided "as is" without express or implied warranty.
23.\"
24.Dd February 26, 2021
25.Dt NEWSYSLOG.CONF 5
26.Os
27.Sh NAME
28.Nm newsyslog.conf
29.Nd
30.Xr newsyslog 8
31configuration file
32.Sh DESCRIPTION
33The
34.Nm
35file is used to set log file rotation configuration for the
36.Xr newsyslog 8
37utility.
38Configuration may designate that logs are rotated based on
39size, last rotation time, or time of day.
40The
41.Nm
42file can also be used to designate secure permissions to log
43files at rotation time.
44During initialization,
45.Xr newsyslog 8
46reads a configuration file,
47normally
48.Pa /etc/newsyslog.conf ,
49to determine which logs may potentially be rotated and archived.
50Each line has five mandatory fields and four optional fields,
51separated with whitespace.
52Blank lines or lines beginning with
53.Ql #
54are ignored.
55If
56.Ql #
57is placed in the middle of the line, the
58.Ql #
59character and the rest of the line after it is ignored.
60To prevent special meaning, the
61.Ql #
62character may be escaped with
63.Ql \e ;
64in this case preceding
65.Ql \e
66is removed and
67.Ql #
68is treated as an ordinary character.
69The fields of the configuration file are as follows:
70.Bl -tag -width indent
71.It Ar logfile_name
72Name of the system log file to be archived,
73or one of the literal strings
74.Dq Aq Li default ,
75or
76.Dq Aq Li include .
77The special default entry will only be used if a log file
78name is given as a command line argument to
79.Xr newsyslog 8 ,
80and if that log file name is not matched by any other
81line in the configuration file.
82The include entry is used to include other configuration
83files and supports globbing.
84.It Ar owner : Ns Ar group
85This optional field specifies the owner and group for the archive file.
86The
87.Ql \&:
88is essential regardless if the
89.Ar owner
90or
91.Ar group
92field is left blank or contains a value.
93The field may be numeric, or a name which is present in
94.Pa /etc/passwd
95or
96.Pa /etc/group .
97.It Ar mode
98Specify the file mode of the log file and archives.
99Valid mode bits are
100.Dv 0666 .
101(That is, read and write permissions for the rotated log may be specified for
102the owner, group, and others.)
103All other mode bits are ignored.
104.It Ar count
105Specify the maximum number of archive files which may exist.
106This does not consider the current log file.
107.It Ar size
108When the size of the log file reaches
109.Ar size
110in kilobytes, the log file will be trimmed as described above.
111If this field contains an asterisk
112.Pq Ql * ,
113the log file will not be trimmed based on size.
114.It Ar when
115The
116.Ar when
117field may consist of an interval, a specific time, or both.
118If the
119.Ar when
120field contains an asterisk
121.Pq Ql * ,
122log rotation will solely depend on the contents of the
123.Ar size
124field.
125Otherwise, the
126.Ar when
127field consists of an optional interval in hours, usually followed
128by an
129.So Li \&@ Sc Ns No -sign
130and a time in restricted
131.Tn ISO 8601
132format.
133Additionally, the format may also be constructed with a
134.Ql $
135sign along with a rotation time specification of once
136a day, once a week, or once a month.
137.Pp
138Time based trimming happens only if
139.Xr newsyslog 8
140is run within one hour of the specified time.
141If an interval is specified, the log file will be trimmed if that many
142hours have passed since the last rotation.
143When both a time and an interval are
144specified then both conditions must be satisfied for the rotation to
145take place.
146.Pp
147There is no provision for the specification of a timezone.
148There is little point in specifying an explicit minutes or
149seconds component in the current implementation, since the only comparison is
150.Dq within the hour .
151.Pp
152.Sy ISO 8601 restricted time format :
153.Pp
154The lead-in character for a restricted
155.Tn ISO 8601
156time is an
157.Ql @
158sign.
159The particular format of the time in restricted
160.Tn ISO 8601
161is:
162.Sm off
163.Oo Oo Oo Oo Oo
164.Va cc Oc
165.Va yy Oc
166.Va mm Oc
167.Va dd Oc
168.Oo
169.Li T Oo
170.Va hh Oo
171.Va mm Oo
172.Va ss
173.Oc Oc Oc Oc Oc .
174.Sm on
175Optional date fields default to the appropriate component of the
176current date; optional time fields default to midnight; hence if today
177is January 22, 1999, the following date specifications are all
178equivalent:
179.Pp
180.Bl -item -compact -offset indent
181.It
182.Sq Li 19990122T000000
183.It
184.Sq Li 990122T000000
185.It
186.Sq Li 0122T000000
187.It
188.Sq Li 22T000000
189.It
190.Sq Li T000000
191.It
192.Sq Li T0000
193.It
194.Sq Li T00
195.It
196.Sq Li 22T
197.It
198.Sq Li T
199.It
200.Sq Li \&
201.El
202.Pp
203.Sy Day, week, and month time format:
204.Pp
205The lead-in character for day, week, and month specification is a
206.Ql $
207sign.
208The particular format of day, week, and month specification is:
209.Op Li D Ns Va hh ,
210.Op Li W Ns Va w Ns Op Li D Ns Va hh ,
211and
212.Op Li M Ns Va dd Ns Op Li D Ns Va hh ,
213respectively.
214Optional time fields default to midnight.
215The ranges for day and hour specifications are:
216.Pp
217.Bl -tag -width indent -offset indent -compact
218.It Ar hh
219hours, range 0..23
220.It Ar w
221day of week, range 0..6, 0 = Sunday
222.It Ar dd
223day of month, range 1..31, or one of the letters
224.Ql L
225or
226.Ql l
227to specify the last day of the month.
228.El
229.Pp
230Some examples:
231.Pp
232.Bl -tag -width indent -offset indent -compact
233.It Li $D0
234rotate every night at midnight
235(same as
236.Li @T00 )
237.It Li $D23
238rotate every day at 23:00
239(same as
240.Li @T23 )
241.It Li $W0D23
242rotate every week on Sunday at 23:00
243.It Li $W5D16
244rotate every week on Friday at 16:00
245.It Li $M1D0
246rotate at the first day of every month at midnight
247(i.e., the start of the day; same as
248.Li @01T00 )
249.It Li $M5D6
250rotate on every fifth day of month at 6:00
251(same as
252.Li @05T06 )
253.El
254.It Ar flags
255This optional field is made up of one or more characters
256that specify any special processing to be done for the log
257files matched by this line.
258The following are valid flags:
259.Bl -tag -width indent
260.It Cm B
261indicates that the log file is a binary file, or has some
262special format.
263Usually
264.Xr newsyslog 8
265inserts an
266.Tn ASCII
267message into a log file during rotation.
268This message is used to indicate
269when, and sometimes why the log file was rotated.
270If
271.Cm B
272is specified, then that informational message will not be
273inserted into the log file.
274.It Cm C
275indicates that the log file should be created if it does not
276already exist, and if the
277.Fl C
278option was also specified on the command line.
279.It Cm D
280indicates that
281.Xr newsyslog 8
282should set the
283.Dv UF_NODUMP
284flag when creating a new version of
285this log file.
286This option would affect how the
287.Xr dump 8
288command treats the log file when making a file system backup.
289.It Cm E
290indicates that the log file should not be rotated when its
291size is zero.
292The
293.Cm E
294flag is mostly useful in conjunction with
295.Cm B
296flag to prevent
297.Xr newsyslog 8
298from inserting an informational
299.Tn ASCII
300message into the new file.
301.It Cm G
302indicates that the specified
303.Ar logfile_name
304is a shell pattern, and that
305.Xr newsyslog 8
306should archive all filenames matching that pattern using the
307other options on this line.
308See
309.Xr glob 3
310for details on syntax and matching rules.
311.It Cm J
312indicates that
313.Xr newsyslog 8
314should attempt to save disk space by compressing the rotated
315log file using
316.Xr bzip2 1 .
317.It Cm N
318indicates that there is no process which needs to be signaled
319when this log file is rotated.
320.It Cm p
321indicates that the zero-th rotated file should not be compressed.
322.It Cm R
323if this flag is set the
324.Xr newsyslog 8
325will run shell command defined in
326.Ar path_to_pid_cmd_file
327after rotation instead of trying to send signal to a process id
328stored in the file.
329.It Cm T
330if this flag is set the informational rotation message written to
331the log file will be in the format specified by RFC5424.
332Normally, the rotation message is written in the traditional (RFC3164)
333syslog format.
334.It Cm U
335indicates that the file specified by
336.Ar path_to_pid_cmd_file
337will contain the ID for a process group instead of a process.
338This option also requires that the first line in that file
339be a negative value to distinguish it from a process ID.
340.It Cm X
341indicates that
342.Xr newsyslog 8
343should attempt to save disk space by compressing the rotated
344log file using
345.Xr xz 1 .
346.It Cm Y
347indicates that
348.Xr newsyslog 8
349should attempt to save disk space by compressing the rotated
350log file using
351.Xr zstd 1 .
352.It Cm Z
353indicates that
354.Xr newsyslog 8
355should attempt to save disk space by compressing the rotated
356log file using
357.Xr gzip 1 .
358.It Fl
359a minus sign will not cause any special processing, but it
360can be used as a placeholder to create a
361.Ar flags
362field when you need to specify any of the following fields.
363.El
364.It Ar path_to_pid_cmd_file
365This optional field specifies the file name containing a daemon's
366process ID or to find a group process ID if the
367.Cm U
368flag was specified.
369If this field is present, a
370.Ar signal
371is sent to the process ID contained in this file.
372If this field is not present and the
373.Cm N
374flag has not been specified, then a
375.Dv SIGHUP
376signal will be sent to
377.Xr syslogd 8
378or to the process id found in the file specified by
379.Xr newsyslog 8 Ns 's
380.Fl S
381switch.
382This field must start with
383.Ql /
384in order to be recognized properly.
385When used with the
386.Cm R
387flag, the file is treated as a path to a binary to be executed
388by the
389.Xr newsyslog 8
390after rotation instead of sending the signal out.
391.It Ar signal
392This optional field specifies the signal that will be sent to the daemon
393process (or to all processes in a process group, if the
394.Cm U
395flag was specified).
396If this field is not present, then a
397.Dv SIGHUP
398signal will be sent.
399Signal names
400must start with
401.Dq SIG
402and be the signal name, e.g.,
403.Dv SIGUSR1 .
404Alternatively,
405.Ar signal
406can be the signal number, e.g., 30 for
407.Dv SIGUSR1 .
408.El
409.Sh EXAMPLES
410The following is an example of the
411.Dq Aq Li include
412entry:
413.Dl "<include> /etc/newsyslog-local.conf"
414.Sh SEE ALSO
415.Xr bzip2 1 ,
416.Xr gzip 1 ,
417.Xr xz 1 ,
418.Xr zstd 1 ,
419.Xr syslog 3 ,
420.Xr chown 8 ,
421.Xr newsyslog 8 ,
422.Xr syslogd 8
423.Pp
424.Rs
425.%A C. Lonvick
426.%T The BSD syslog Protocol
427.%O RFC3164
428.Re
429.Rs
430.%A R. Gerhards
431.%T The Syslog Protocol
432.%O RFC5424
433.Re
434.Sh HISTORY
435This manual page first appeared in
436.Fx 4.10 .
437