]> granicus.if.org Git - apache/blob - docs/manual/programs/rotatelogs.xml
Add in new option for rotatelogs: -f
[apache] / docs / manual / programs / rotatelogs.xml
1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="rotatelogs.xml.meta">
24 <parentdocument href="./">Programs</parentdocument>
25
26   <title>rotatelogs - Piped logging program to rotate Apache logs</title>
27
28 <summary>
29      <p><code>rotatelogs</code> is a simple program for use in
30      conjunction with Apache's piped logfile feature.  It supports
31      rotation based on a time interval or maximum size of the log.</p>
32 </summary>
33
34 <section id="synopsis"><title>Synopsis</title>
35
36      <p><code><strong>rotatelogs</strong>
37      [ -<strong>l</strong> ]
38      [ -<strong>f</strong> ]
39      <var>logfile</var>
40      <var>rotationtime</var>|<var>filesize</var>M 
41      [ <var>offset</var> ]</code></p>
42 </section>
43
44 <section id="options"><title>Options</title>
45
46 <dl>
47
48 <dt><code>-l</code></dt>
49 <dd>Causes the use of local time rather than GMT as the base for the
50 interval or for <code>strftime(3)</code> formatting with size-based 
51 rotation.  Note that using <code>-l</code> in an environment which
52 changes the GMT offset (such as for BST or DST) can lead to unpredictable
53 results!</dd>
54
55 <dt><code>-f</code></dt>
56 <dd>Causes the logfile to be opened immediately, as soon as
57 <code>rotatelogs</code> starts, instead of waiting for the
58 first logfile entry to be read (for non-busy sites, there may be
59 a substantial delay between when the server is started
60 and when the first request is handled, meaning that the
61 associated logfile does not "exist" until then, which
62 causes problems from some automated logging tools)</dd>
63
64 <dt><code><var>logfile</var></code></dt>
65
66 <dd>The path plus basename of the logfile.  If <var>logfile</var>
67 includes any '%' characters, it is treated as a format string for
68 <code>strftime(3)</code>.  Otherwise, the suffix
69 <var>.nnnnnnnnnn</var> is automatically added and is the time in
70 seconds.  Both formats compute the start time from the beginning of
71 the current period.  For example, if a rotation time of 86400 is 
72 specified, the hour, minute, and second fields created from the
73 <code>strftime(3)</code> format will all be zero, referring to the
74 beginning of the current 24-hour period (midnight).</dd>
75
76 <dt><code><var>rotationtime</var></code></dt>
77
78 <dd>The time between log file rotations in seconds.  The rotation
79 occurs at the beginning of this interval.  For example, if the
80 rotation time is 3600, the log file will be rotated at the beginning
81 of every hour; if the rotation time is 86400, the log file will be
82 rotated every night at midnight.  (If no data is logged during an
83 interval, no file will be created.)</dd>
84
85 <dt><code><var>filesize</var>M</code></dt>
86
87 <dd>The maximum file size in megabytes followed by the letter
88 <code>M</code> to specify size rather than time.</dd>
89
90 <dt><code><var>offset</var></code></dt>
91
92 <dd>The number of minutes offset from UTC.  If omitted, zero is
93 assumed and UTC is used.  For example, to use local time in the zone
94 UTC -5 hours, specify a value of <code>-300</code> for this argument.
95 In most cases, <code>-l</code> should be used instead of specifying
96 an offset.</dd>
97
98 </dl>
99 </section>
100
101 <section id="examples"><title>Examples</title>
102
103 <example>
104      CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
105 </example>
106          
107      <p>This creates the files /var/logs/logfile.nnnn where nnnn  is
108      the system time at which the log nominally starts (this time
109      will always be a multiple of the rotation time, so  you  can
110      synchronize cron scripts with it).  At the end of each rotation
111      time (here after 24 hours) a new log is started.</p>
112
113 <example>
114      CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
115 </example>
116          
117      <p>This creates the files /var/logs/logfile.yyyy.mm.dd where
118      yyyy is the year, mm is the month, and dd is the day of the month.
119      Logging will switch to a new file every day at midnight, local time.</p>
120
121 <example>
122      CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
123 </example>
124
125      <p>This configuration will rotate the logfile whenever it reaches
126      a size of 5 megabytes.</p>
127
128 <example>
129      ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
130 </example>
131      <p>This configuration will rotate the error logfile whenever it
132      reaches a size of 5 megabytes, and the suffix to the logfile name
133      will be created of the form
134      <code>errorlog.YYYY-mm-dd-HH_MM_SS</code>.</p>
135  
136 </section>
137
138 <section id="portability"><title>Portability</title>
139
140 <p>The following logfile format string substitutions should be
141 supported by all <code>strftime(3)</code> implementations, see
142 the <code>strftime(3)</code> man page for library-specific
143 extensions.</p>
144
145 <table border="1" style="zebra">
146 <tr><td><code>%A</code></td><td>full weekday name (localized)</td></tr>
147 <tr><td><code>%a</code></td><td>3-character weekday name (localized)</td></tr>
148 <tr><td><code>%B</code></td><td>full month name (localized)</td></tr>
149 <tr><td><code>%b</code></td><td>3-character month name (localized)</td></tr>
150 <tr><td><code>%c</code></td><td>date and time (localized)</td></tr>
151 <tr><td><code>%d</code></td><td>2-digit day of month</td></tr>
152 <tr><td><code>%H</code></td><td>2-digit hour (24 hour clock)</td></tr>
153 <tr><td><code>%I</code></td><td>2-digit hour (12 hour clock)</td></tr>
154 <tr><td><code>%j</code></td><td>3-digit day of year</td></tr>
155 <tr><td><code>%M</code></td><td>2-digit minute</td></tr>
156 <tr><td><code>%m</code></td><td>2-digit month</td></tr>
157 <tr><td><code>%p</code></td><td>am/pm of 12 hour clock (localized)</td></tr>
158 <tr><td><code>%S</code></td><td>2-digit second</td></tr>
159 <tr><td><code>%U</code></td><td>2-digit week of year 
160 (Sunday first day of week)</td></tr>
161 <tr><td><code>%W</code></td><td>2-digit week of year 
162 (Monday first day of week)</td></tr>
163 <tr><td><code>%w</code></td><td>1-digit weekday 
164 (Sunday first day of week)</td></tr>
165 <tr><td><code>%X</code></td><td>time (localized)</td></tr>
166 <tr><td><code>%x</code></td><td>date (localized)</td></tr>
167 <tr><td><code>%Y</code></td><td>4-digit year</td></tr>
168 <tr><td><code>%y</code></td><td>2-digit year</td></tr>
169 <tr><td><code>%Z</code></td><td>time zone name</td></tr>
170 <tr><td><code>%%</code></td><td>literal `%'</td></tr>
171 </table>
172
173 </section>
174 </manualpage>