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