1ROTATELOGS(8) rotatelogs ROTATELOGS(8)
2
3
4
6 rotatelogs - Piped logging program to rotate Apache logs
7
8
10 rotatelogs [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -v ] [ -e ] [
11 -c ] logfile rotationtime|filesize(B|K|M|G) [ offset ]
12
13
14
16 rotatelogs is a simple program for use in conjunction with Apache's
17 piped logfile feature. It supports rotation based on a time interval or
18 maximum size of the log.
19
20
21
23 -l Causes the use of local time rather than GMT as the base for the
24 interval or for strftime(3) formatting with size-based rotation.
25
26 -L linkname
27 Causes a hard link to be made from the current logfile to the
28 specified link name. This can be used to watch the log continu‐
29 ously across rotations using a command like tail -F linkname.
30
31 -p program
32 If given, rotatelogs will execute the specified program every
33 time a new log file is opened. The filename of the newly opened
34 file is passed as the first argument to the program. If execut‐
35 ing after a rotation, the old log file is passed as the second
36 argument. rotatelogs does not wait for the specified program to
37 terminate before continuing to operate, and will not log any
38 error code returned on termination. The spawned program uses the
39 same stdin, stdout, and stderr as rotatelogs itself, and also
40 inherits the environment.
41
42 -f Causes the logfile to be opened immediately, as soon as rotatel‐
43 ogs starts, instead of waiting for the first logfile entry to be
44 read (for non-busy sites, there may be a substantial delay
45 between when the server is started and when the first request is
46 handled, meaning that the associated logfile does not "exist"
47 until then, which causes problems from some automated logging
48 tools)
49
50 -t Causes the logfile to be truncated instead of rotated. This is
51 useful when a log is processed in real time by a command like
52 tail, and there is no need for archived data. No suffix will be
53 added to the filename, however format strings containing '%'
54 characters will be respected.
55
56 -v Produce verbose output on STDERR. The output contains the result
57 of the configuration parsing, and all file open and close
58 actions.
59
60 -e Echo logs through to stdout. Useful when logs need to be further
61 processed in real time by a further tool in the chain.
62
63 -c Create log file for each interval, even if empty.
64
65 logfile
66
67 rotationtime
68 The time between log file rotations in seconds. The rotation
69 occurs at the beginning of this interval. For example, if the
70 rotation time is 3600, the log file will be rotated at the
71 beginning of every hour; if the rotation time is 86400, the log
72 file will be rotated every night at midnight. (If no data is
73 logged during an interval, no file will be created.)
74
75 filesize(B|K|M|G)
76 The maximum file size in followed by exactly one of the letters
77 B (Bytes), K (KBytes), M (MBytes) or G (GBytes). .PP When time
78 and size are specified, the size must be given after the time.
79 Rotation will occur whenever either time or size limits are
80 reached.
81
82 offset The number of minutes offset from UTC. If omitted, zero is
83 assumed and UTC is used. For example, to use local time in the
84 zone UTC -5 hours, specify a value of -300 for this argument. In
85 most cases, -l should be used instead of specifying an offset.
86
87
89 CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
90
91
92
93 This creates the files /var/logs/logfile.nnnn where nnnn is the system
94 time at which the log nominally starts (this time will always be a mul‐
95 tiple of the rotation time, so you can synchronize cron scripts with
96 it). At the end of each rotation time (here after 24 hours) a new log
97 is started.
98
99
100 CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
101
102
103
104 This creates the files /var/logs/logfile.yyyy.mm.dd where yyyy is the
105 year, mm is the month, and dd is the day of the month. Logging will
106 switch to a new file every day at midnight, local time.
107
108
109 CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
110
111
112
113 This configuration will rotate the logfile whenever it reaches a size
114 of 5 megabytes.
115
116
117 ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
118
119
120
121 This configuration will rotate the error logfile whenever it reaches a
122 size of 5 megabytes, and the suffix to the logfile name will be created
123 of the form errorlog.YYYY-mm-dd-HH_MM_SS.
124
125
126 CustomLog "|bin/rotatelogs -t /var/logs/logfile 86400" common
127
128
129
130 This creates the file /var/logs/logfile, truncating the file at startup
131 and then truncating the file once per day. It is expected in this sce‐
132 nario that a separate process (such as tail) would process the file in
133 real time.
134
135
137 The following logfile format string substitutions should be supported
138 by all strftime(3) implementations, see the strftime(3) man page for
139 library-specific extensions.
140
141
142 · %A - full weekday name (localized)
143
144
145 · %a - 3-character weekday name (localized)
146
147
148 · %B - full month name (localized)
149
150
151 · %b - 3-character month name (localized)
152
153
154 · %c - date and time (localized)
155
156
157 · %d - 2-digit day of month
158
159
160 · %H - 2-digit hour (24 hour clock)
161
162
163 · %I - 2-digit hour (12 hour clock)
164
165
166 · %j - 3-digit day of year
167
168
169 · %M - 2-digit minute
170
171
172 · %m - 2-digit month
173
174
175 · %p - am/pm of 12 hour clock (localized)
176
177
178 · %S - 2-digit second
179
180
181 · %U - 2-digit week of year (Sunday first day of week)
182
183
184 · %W - 2-digit week of year (Monday first day of week)
185
186
187 · %w - 1-digit weekday (Sunday first day of week)
188
189
190 · %X - time (localized)
191
192
193 · %x - date (localized)
194
195
196 · %Y - 4-digit year
197
198
199 · %y - 2-digit year
200
201
202 · %Z - time zone name
203
204
205 · %% - literal `%'
206
207
208
209
210Apache HTTP Server 2011-10-28 ROTATELOGS(8)