summary refs log tree commit diff
path: root/man/svlogd.8
blob: 7114bbafb66b0532fda6454a8cb47e61b5e08115 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
.TH svlogd 8
.SH NAME
svlogd \- runit's service logging daemon
.SH SYNOPSIS
.B svlogd
[\-tv] [\-r
.I c\fR] [\-R
.I xyz\fR] [\-l
.I n\fR] [\-b
.I n\fR]
.I logs
.SH DESCRIPTION
.I logs
consists of one or more arguments, each specifying a directory.
.P
.B svlogd
continuously reads log data from its standard input, optionally filters log
messages, and writes the data to one or more automatically rotated
.IR logs .
.P
Recent log files can automatically be processed by an arbitrary processor
program when they are rotated, and
.B svlogd
can be told to alert selected log messages to standard error.
.P
.B svlogd
runs until it sees end-of-file on standard input or is sent a TERM signal,
see below.

.SS LOG DIRECTORY
A log directory
.I log
contains some number of old log files, and the current log file
.IR current .
Old log files have a file name starting with
.I @
followed by a precise timestamp (see
.BR tai64n (8)),
indicating when
.I current
was rotated and renamed to this file.
.P
A log directory additionally contains the lock file
.IR lock ,
maybe
.I state
and
.IR newstate ,
and optionally the file
.IR config .
.B svlogd
creates necessary files if they don't exist.
.SS LOG FILE ROTATION
.B svlogd
appends selected log messages to the
.I current
log file.
If
.I current
has
.I size
bytes or more size (or there is a new-line within the last
.I len
of
.I size
bytes)
.I current
is rotated:
.P
.B svlogd
closes
.IR current ,
changes permission of
.I current
to 0755, renames
.I current
to
.RI @ timestamp\fR.s,
and starts with a new empty
.IR current .
If
.B svlogd
sees
.I num
or more old log files in
.IR dir ,
it removes the oldest.
.SS PROCESSOR
If
.B svlogd
is told to process recent log files, it saves
.I current
to
.RI @ timestamp\fR.u,
feeds
.RI @ timestamp\fR.u
through ``sh \-c "\fIprocessor\fR"''
and writes the output to
.RI @ timestamp\fR.t.
If the
.I processor
finishes successfully,
.RI @ timestamp\fR.u
is deleted and
.RI @ timestamp\fR.t
is renamed to
.RI @ timestamp\fR.s,
otherwise
.RI @ timestamp\fR.t
is deleted and the
.I processor
is started again.
.B svlogd
also saves any output that the
.I processor
writes to file descriptor 5, and make that output available on
file descriptor 4 when it runs
.I processor
on the next log file rotation.
.P
A
.I processor
is run in the background.
If
.B svlogd
sees a previously started
.I processor
still running when trying to start a new one for the same
.IR log ,
it blocks until the currently running
.I processor
has finished successfully.
Only the HUP signal works in that situation.
Note that this may block any program feeding its log data to
.BR svlogd.

.SS CONFIG
On startup, and after receiving a HUP signal,
.B svlogd
checks for each
.I log
if the configuration file
.I log/config
exists, and if so, reads the file line by line and adjusts configuration for
.I log
as follows:
.P
If the line is empty, less than two characters long, or starts with a ``#'',
it is ignored.
A line of the form
.TP
.RI s size
sets the maximum file size of
.I current
when
.B svlogd
should rotate the current log file to
.I size
bytes.
Default is 1000000.
If
.I size
is zero,
.B svlogd
doesn't rotate log files.
You should set
.I size
to at least (2 *
.IR len ).
.TP
.RI n num
sets the maximum number of old log files
.B svlogd
should maintain to
.IR num .
If
.B svlogd
sees more that
.I num
old log files in
.I log
after log file rotation, it deletes the oldest one.
Default is 10.
.TP
.RI ! processor
tells
.B svlogd
to feed each recent log file through
.I processor
(see above) on log file rotation.
By default log files are not processed.
.P
If a line starts with a
.IR \- ,
.IR + ,
.IR e ,
or
.IR E ,
.B svlogd
matches the first
.I len
characters of each log message against
.I pattern
and acts accordingly:
.TP
.RI \- pattern
the log message is deselected.
.TP
.RI + pattern
the log message is selected
.TP
.RI e pattern
log messages matching
.I pattern
are printed to standard error.
.TP
.RI E pattern
log messages not matching
.I pattern
are printed to standard error.
.P
Initially each line is selected.
Deselected log messages are discarded from
.IR log .
.SH PATTERN MATCHING
.B svlogd
matches a log message against the string
.I pattern
as follows:
.P
.I pattern
is applied to the log message one character by one, starting with the first.
A character not a star (``*'') and not a plus (``+'') matches itself.
A plus matches the next character in
.I pattern
in the log message one or more times.
A star before the end of
.I pattern
matches any string in the log message that does not include the next
character in
.IR pattern .
A star at the end of
.I pattern
matches any string.
.SH OPTIONS
.TP
.B \-t
timestamp.
Prefix each selected line with a precise timestamp (see
.BR tai64n (8))
when writing to
.I log
or to standard error.
.TP
.B \-r \fIc
replace.
.I c
must be a single character.
Replace non-printable characters in log messages with
.IR c .
Characters are replaced before pattern matching is applied.
.TP
.B \-R \fIxyz
replace charset.
Additionally to non-printable characters, replace all characters found in
.I xyz
with
.I c
(default ``_'').
.TP
.B \-l \fIlen
line length.
Pattern matching applies to the first
.I len
characters of a log message only.
Default is 1000.
.TP
.B \-b \fIbuflen
buffer size.
Set the size of the buffer
.B svlogd
uses when reading from standard input and writing to
.I logs
to
.IR buflen .
Default is 1024.
.I buflen
must be greater than
.IR len .
.TP
.B \-v
verbose.
Print verbose messages to standard error.
.SH SIGNALS
If
.B svlogd
is sent a HUP signal, it closes and reopens all
.IR logs ,
and updates their configuration according to
.IR log/config .
.P
If
.B svlogd
is sent a TERM signal, or if it sees end-of-file on standard input, it stops
reading standard input, processes the data in the buffer, waits for all
.I processor
subprocesses to finish if any, and exits 0 as soon as possible.
.P
If
.B svlogd
is sent an ALRM signal, it forces log file rotation for all
.I logs
with a non empty
.I current
log file.
.SH SEE ALSO
runsv(8),
runsvstat(8),
runsvctrl(8),
runsvdir(8),
runsvchdir(8),
runit(8),
runit-init(8),
multilog(8)
.P
http://smarden.org/runit/
.SH AUTHOR
Gerrit Pape <pape@smarden.org>