1ROTATELOGS(8)                     rotatelogs                     ROTATELOGS(8)
2
3
4

NAME

6       rotatelogs - Piped logging program to rotate Apache logs
7
8

SYNOPSIS

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

SUMMARY

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

OPTIONS

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
29       -p program
30              If given, rotatelogs will execute the  specified  program  every
31              time  a new log file is opened. The filename of the newly opened
32              file is passed as the first argument to the program. If  execut‐
33              ing  after  a rotation, the old log file is passed as the second
34              argument. rotatelogs does not wait for the specified program  to
35              terminate before continuing to operate, and will not log any er‐
36              ror code returned on termination. The spawned program  uses  the
37              same  stdin,  stdout,  and stderr as rotatelogs itself, and also
38              inherits the environment.
39
40       -f     Causes the logfile to be opened immediately, as soon as rotatel‐
41              ogs starts, instead of waiting for the first logfile entry to be
42              read (for non-busy sites, there may be a substantial  delay  be‐
43              tween  when  the server is started and when the first request is
44              handled, meaning that the associated logfile  does  not  "exist"
45              until  then,  which  causes problems from some automated logging
46              tools)
47
48       -D     Creates the parent directories of the path  that  the  log  file
49              will  be  placed  in  if  they do not already exist. This allows
50              strftime(3) formatting to be used in the path and not  just  the
51              filename.
52
53       -t     Causes  the  logfile to be truncated instead of rotated. This is
54              useful when a log is processed in real time by  a  command  like
55              tail,  and there is no need for archived data. No suffix will be
56              added to the filename, however  format  strings  containing  '%'
57              characters will be respected.
58
59       -T     Causes  all but the initial logfile to be truncated when opened.
60              This is useful when the format string  contains  something  that
61              will  loop  around,  such  as the day of the month. Available in
62              2.4.56 and later.
63
64       -v     Produce verbose output on STDERR. The output contains the result
65              of  the  configuration  parsing, and all file open and close ac‐
66              tions.
67
68       -e     Echo logs through to stdout. Useful when logs need to be further
69              processed in real time by a further tool in the chain.
70
71       -c     Create log file for each interval, even if empty.
72
73       -n number-of-files
74              Use a circular list of filenames without timestamps. This option
75              overwrites log files at startup and during rotation. With -n  3,
76              the  series of log files opened would be "logfile", "logfile.1",
77              "logfile.2", then overwriting "logfile". When this program first
78              opens  "logfile",  the file will only be truncated if -t is also
79              provided. Every subsequent rotation will always begin with trun‐
80              cation  of  the  target file. For size based rotation without -t
81              and existing log files in place, this option may result in unin‐
82              tuitive behavior such as initial log entries being sent to "log‐
83              file.1", and entries in "logfile.1" not being preserved even  if
84              later "logfile.n" have not yet been used. Available in 2.4.5 and
85              later.
86
87       logfile
88
89       rotationtime
90              The time between log file rotations in seconds. The rotation oc‐
91              curs  at the beginning of this interval. For example, if the ro‐
92              tation time is 3600, the log file will be rotated at the  begin‐
93              ning  of every hour; if the rotation time is 86400, the log file
94              will be rotated every night at midnight. (If no data  is  logged
95              during an interval, no file will be created.)
96
97       filesize(B|K|M|G)
98              The  maximum file size in followed by exactly one of the letters
99              B (Bytes), K (KBytes), M (MBytes) or G (GBytes). .PP  When  time
100              and  size  are specified, the size must be given after the time.
101              Rotation will occur whenever either  time  or  size  limits  are
102              reached.
103
104       offset The  number  of minutes offset from UTC. If omitted, zero is as‐
105              sumed and UTC is used. For example, to use  local  time  in  the
106              zone UTC -5 hours, specify a value of -300 for this argument. In
107              most cases, -l should be used instead of specifying an offset.
108
109

EXAMPLES

111            CustomLog "|bin/rotatelogs /var/log/logfile 86400" common
112
113
114
115       This creates the files /var/log/logfile.nnnn where nnnn is  the  system
116       time at which the log nominally starts (this time will always be a mul‐
117       tiple of the rotation time, so you can synchronize  cron  scripts  with
118       it).  At  the end of each rotation time (here after 24 hours) a new log
119       is started.
120
121
122            CustomLog "|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400" common
123
124
125
126       This creates the files /var/log/logfile.yyyy.mm.dd where  yyyy  is  the
127       year,  mm  is  the  month, and dd is the day of the month. Logging will
128       switch to a new file every day at midnight, local time.
129
130
131            CustomLog "|bin/rotatelogs /var/log/logfile 5M" common
132
133
134
135       This configuration will rotate the logfile whenever it reaches  a  size
136       of 5 megabytes.
137
138
139            ErrorLog "|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H_%M_%S 5M"
140
141
142
143       This  configuration will rotate the error logfile whenever it reaches a
144       size of 5 megabytes, and the suffix to the logfile name will be created
145       of the form errorlog.YYYY-mm-dd-HH_MM_SS.
146
147
148            CustomLog "|bin/rotatelogs -t /var/log/logfile 86400" common
149
150
151
152       This  creates the file /var/log/logfile, truncating the file at startup
153       and then truncating the file once per day. It is expected in this  sce‐
154       nario  that a separate process (such as tail) would process the file in
155       real time.
156
157
158            CustomLog "|bin/rotatelogs -T /var/log/logfile.%d 86400" common
159
160
161
162       If the server is started (or restarted) on the first of the month, this
163       appends to /var/log/logfile.01. When a log entry is written on the sec‐
164       ond of the month, /var/log/logfile.02 is truncated and new entries will
165       be added to the top. This example keeps approximately 1 months worth of
166       logs without external maintenance.
167
168

PORTABILITY

170       The following logfile format string substitutions should  be  supported
171       by  all  strftime(3)  implementations, see the strftime(3) man page for
172       library-specific extensions.
173
174
175%A - full weekday name (localized)
176
177
178%a - 3-character weekday name (localized)
179
180
181%B - full month name (localized)
182
183
184%b - 3-character month name (localized)
185
186
187%c - date and time (localized)
188
189
190%d - 2-digit day of month
191
192
193%H - 2-digit hour (24 hour clock)
194
195
196%I - 2-digit hour (12 hour clock)
197
198
199%j - 3-digit day of year
200
201
202%M - 2-digit minute
203
204
205%m - 2-digit month
206
207
208%p - am/pm of 12 hour clock (localized)
209
210
211%S - 2-digit second
212
213
214%U - 2-digit week of year (Sunday first day of week)
215
216
217%W - 2-digit week of year (Monday first day of week)
218
219
220%w - 1-digit weekday (Sunday first day of week)
221
222
223%X - time (localized)
224
225
226%x - date (localized)
227
228
229%Y - 4-digit year
230
231
232%y - 2-digit year
233
234
235%Z - time zone name
236
237
238%% - literal `%'
239
240
241
242
243Apache HTTP Server                2023-03-05                     ROTATELOGS(8)
Impressum