-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogdemux.1
198 lines (193 loc) · 3.33 KB
/
logdemux.1
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
.\" This document is in the public domain.
.\" vim: fdm=marker
.
.\" FRONT MATTER {{{
.Dd Oct 10, 2012
.Os
.Dt LOGDEMUX 1
.
.Sh NAME
.Nm logdemux
.Nd Logfile demultiplexer
.\" FRONT MATTER }}}
.
.\" SYNOPSIS {{{
.Sh SYNOPSIS
.Nm
.Ar rules
.Ar prefix
.\" SYNOPSIS }}}
.
.\" DESCRIPTION {{{
.Sh DESCRIPTION
.Nm
stores lines read from the standard input into different
files based on matching those lines with user-specified
regular expressions.
.
.Bl -tag -width "xx"
.It Ar rules
configuration file
.It Ar prefix
substituted into
.Li sink
values
.Pq Li \&%P
.El
.Pp
.
.Ss Rules
.
The filtering rules are given in an INI-formatted file, see
Iniphile for details on general syntax.
.Pp
Configuration must contain a
.Ql rules
section, with
.Ql order
property.
Its value is expected to list rule section names in the order they
should be used.
.Pp
Each rule section defines a rule with properties
.Ql match ,
.Ql sink ,
and optionally
.Ql final .
.Pp
.
.Bl -tag -width "xx"
.It Li match
Perl-compatible regular expression.
.
.It Li sink
Log file path.
.Li \&%P
is replaced with the
.Ar prefix
argument.
.Li \&%D
is replaced with current date in the
.Li YYYY-MM-DD
format.
.
.It Li final
Boolean.
.Li true , yes , on , 1
are true, anything else is false.
.El
.
.Ss Operation
Runtime behavior conforms to this pseudocode:
.Bd -literal
for each line of input
for each rule of rules.order
if rule.match line
write line to rule.sink
if rule.final
next line
.Ed
.
.\" DESCRIPTION }}}
.\" .Sh IMPLEMENTATION NOTES
.\" ENVIRONMENT {{{
.Sh ENVIRONMENT
None.
.\" ENVIRONMENT }}}
.\" .Sh FILES
.\" EXAMPLES {{{
.Sh EXAMPLES
This configures the Apache web server to log requests into
.Pa logs/%D-access_log ,
404's are duplicated into
.Pa logs/%D-404_log .
.Pp
ErrorLog is written into
.Pa logs/%D-error_log ,
except mod_fcgid, which goes into
.Pa logs/%D-mod_fcgid_log ,
except the FCGIWrapper's
.Dv stderr ,
which goes into
.Pa logs/%D-php_log .
.Pp
Note that
.Ql \&%D
is replaced with current date; see
.Sx DESCRIPTION .
.
.Pp
.Pa httpd.conf :
.
.Bd -literal -offset "xx"
LogFormat "%{%Y-%m-%d %H:%M:%S}t D=%D h=%h u=%u s=%>s b=%b r=\e"%r\e""
TransferLog "|/usr/local/bin/logdemux conf/logdemux.access logs/"
ErrorLog "|/usr/local/bin/logdemux conf/logdemux.error logs/"
.Ed
.
.Pp
.Pa logdemux.access :
.
.Bd -literal -offset "xx"
[rules]
order = http-404 default
[http-404]
match = \e<s=404\e>
sink = %P%D-404_log
[default]
match = .
sink = %P%D-access_log
.Ed
.
.Pp
.Pa logdemux.error :
.
.Bd -literal -offset "xx"
[rules]
order = php mod_fcgid default
[php]
match = [ ]mod_fcgid: stderr:[ ]
sink = %P%D-php_log
final = 1
[mod_fcgid]
match = [ ]mod_fcgid:[ ]
sink = %P%D-mod_fcgid_log
final = 1
[default]
match = .
sink = %P%D-error_log
.Ed
.
.\" EXAMPLES }}}
.\" DIAGNOSTICS {{{
.Sh DIAGNOSTICS
.Ss Exit code
.Bl -tag -width "xxxx" -compact
.It 0
successful operation
.It 66
the input file could not be open
.It 65
syntax error in input file
.It 64
wrong (number of) arguments
.El
.\" DIAGNOSTICS }}}
.\" .Sh COMPATIBILITY
.\" .Sh SEE ALSO {{{
.Sh SEE ALSO
.Lk https://github.com/roman-neuhauser/iniphile/ Iniphile
.\" .Sh SEE ALSO }}}
.\" .Sh STANDARDS
.\" .Sh HISTORY
.\" AUTHORS {{{
.Sh AUTHORS
.
.Nm
and this manual page are written by
.An Roman Neuhauser Aq Mt [email protected] .
.Pp
See
.Lk https://github.com/roman-neuhauser/logdemux/ .
.\" AUTHORS }}}
.\" .Sh BUGS