]> granicus.if.org Git - apache/blob - docs/manual/programs/rotatelogs.html.en
Documentation rebuild after recent commits
[apache] / docs / manual / programs / rotatelogs.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>rotatelogs - Piped logging program to rotate Apache logs - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body id="manual-page"><div id="page-header">
19 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
20 <p class="apache">Apache HTTP Server Version 2.5</p>
21 <img alt="" src="../images/feather.png" /></div>
22 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
23 <div id="path">
24 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>rotatelogs - Piped logging program to rotate Apache logs</h1>
25 <div class="toplang">
26 <p><span>Available Languages: </span><a href="../en/programs/rotatelogs.html" title="English">&nbsp;en&nbsp;</a> |
27 <a href="../ko/programs/rotatelogs.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
28 <a href="../tr/programs/rotatelogs.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
29 </div>
30
31      <p><code>rotatelogs</code> is a simple program for use in
32      conjunction with Apache's piped logfile feature.  It supports
33      rotation based on a time interval or maximum size of the log.</p>
34 </div>
35 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
36 <li><img alt="" src="../images/down.gif" /> <a href="#options">Options</a></li>
37 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
38 <li><img alt="" src="../images/down.gif" /> <a href="#portability">Portability</a></li>
39 </ul><h3>See also</h3><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
40 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
41 <div class="section">
42 <h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
43
44      <p><code><strong>rotatelogs</strong>
45      [ -<strong>l</strong> ]
46      [ -<strong>L</strong> <var>linkname</var> ]
47      [ -<strong>p</strong> <var>program</var> ]
48      [ -<strong>f</strong> ]
49      [ -<strong>D</strong> ]
50      [ -<strong>t</strong> ]
51      [ -<strong>v</strong> ]
52      [ -<strong>e</strong> ]
53      [ -<strong>c</strong> ]
54      [ -<strong>n</strong> <var>number-of-files</var> ]
55      <var>logfile</var>
56      <var>rotationtime</var>|<var>filesize</var>(B|K|M|G)
57      [ <var>offset</var> ]</code></p>
58 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
59 <div class="section">
60 <h2><a name="options" id="options">Options</a></h2>
61
62 <dl>
63
64 <dt><code>-l</code></dt>
65 <dd>Causes the use of local time rather than GMT as the base for the
66 interval or for <code>strftime(3)</code> formatting with size-based
67 rotation.</dd>
68
69 <dt><code>-L</code> <var>linkname</var></dt>
70 <dd>Causes a hard link to be made from the current logfile
71 to the specified link name.  This can be used to watch
72 the log continuously across rotations using a command like
73 <code>tail -F linkname</code>.</dd>
74
75 <dt><code>-p</code> <var>program</var></dt>
76
77 <dd>If given, <code>rotatelogs</code> will execute the specified
78 program every time a new log file is opened.  The filename of the
79 newly opened file is passed as the first argument to the program.  If
80 executing after a rotation, the old log file is passed as the second
81 argument.  <code>rotatelogs</code> does not wait for the specified
82 program to terminate before continuing to operate, and will not log
83 any error code returned on termination.  The spawned program uses the
84 same stdin, stdout, and stderr as rotatelogs itself, and also inherits
85 the environment.</dd>
86
87 <dt><code>-f</code></dt>
88 <dd>Causes the logfile to be opened immediately, as soon as
89 <code>rotatelogs</code> starts, instead of waiting for the
90 first logfile entry to be read (for non-busy sites, there may be
91 a substantial delay between when the server is started
92 and when the first request is handled, meaning that the
93 associated logfile does not "exist" until then, which
94 causes problems from some automated logging tools)</dd>
95
96 <dt><code>-D</code></dt>
97 <dd>Creates the parent directories of the path that the log file will be
98 placed in if they do not already exist.  This allows <code>strftime(3)</code>
99 formatting to be used in the path and not just the filename.</dd>
100
101 <dt><code>-t</code></dt>
102 <dd>Causes the logfile to be truncated instead of rotated. This is
103 useful when a log is processed in real time by a command like tail,
104 and there is no need for archived data. No suffix will be added to
105 the filename, however format strings containing '%' characters
106 will be respected.
107 </dd>
108
109 <dt><code>-v</code></dt>
110 <dd>Produce verbose output on STDERR. The output contains
111 the result of the configuration parsing, and all file open and
112 close actions.</dd>
113
114 <dt><code>-e</code></dt>
115 <dd>Echo logs through to stdout. Useful when logs need to be further
116 processed in real time by a further tool in the chain.</dd>
117
118 <dt><code>-c</code></dt>
119 <dd>Create log file for each interval, even if empty.</dd>
120
121 <dt><code>-n <var>number-of-files</var></code></dt>
122 <dd>Use a circular list of filenames without timestamps.
123 With -n 3, the series of log files opened would be
124 "logfile", "logfile.1", "logfile.2", then overwriting "logfile".<br />
125 Available in 2.4.5 and later.</dd>
126
127 <dt><code><var>logfile</var></code></dt>
128
129 <dd><p>The path plus basename of the logfile.  If <var>logfile</var>
130 includes any '%' characters, it is treated as a format string for
131 <code>strftime(3)</code>.  Otherwise, the suffix
132 <var>.nnnnnnnnnn</var> is automatically added and is the time in
133 seconds (unless the -t option is used). Both formats compute the
134 start time from the beginning of the current period.  For example,
135 if a rotation time of 86400 is specified, the hour, minute, and
136 second fields created from the <code>strftime(3)</code> format will
137 all be zero, referring to the beginning of the current 24-hour
138 period (midnight).</p>
139 <p>When using <code>strftime(3)</code> filename formatting,
140 be sure the log file format has enough granularity to produce
141 a different file name each time the logs are rotated.  Otherwise
142 rotation will overwrite the same file instead of starting a new
143 one.  For example, if <var>logfile</var> was
144 <code>/var/log/errorlog.%Y-%m-%d</code> with log rotation at 5
145 megabytes, but 5 megabytes was reached twice in the same day, the
146 same log file name would be produced and log rotation would keep
147 writing to the same file.</p>
148 </dd>
149
150 <dt><code><var>rotationtime</var></code></dt>
151
152 <dd>The time between log file rotations in seconds.  The rotation
153 occurs at the beginning of this interval.  For example, if the
154 rotation time is 3600, the log file will be rotated at the beginning
155 of every hour; if the rotation time is 86400, the log file will be
156 rotated every night at midnight.  (If no data is logged during an
157 interval, no file will be created.)</dd>
158
159 <dt><code><var>filesize</var>(B|K|M|G)</code></dt>
160
161 <dd>The maximum file size in followed by exactly one of the letters
162 <code>B</code> (Bytes), <code>K</code> (KBytes), <code>M</code> (MBytes)
163 or <code>G</code> (GBytes).
164 <p>
165 When time and size are specified, the size must be given after the time.
166 Rotation will occur whenever either time or size limits are reached.
167 </p>
168 </dd>
169
170 <dt><code><var>offset</var></code></dt>
171
172 <dd>The number of minutes offset from UTC.  If omitted, zero is
173 assumed and UTC is used.  For example, to use local time in the zone
174 UTC -5 hours, specify a value of <code>-300</code> for this argument.
175 In most cases, <code>-l</code> should be used instead of specifying
176 an offset.</dd>
177
178 </dl>
179 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
180 <div class="section">
181 <h2><a name="examples" id="examples">Examples</a></h2>
182
183 <div class="example"><p><code>
184      CustomLog "|bin/rotatelogs /var/log/logfile 86400" common
185 </code></p></div>
186
187      <p>This creates the files /var/log/logfile.nnnn where nnnn  is
188      the system time at which the log nominally starts (this time
189      will always be a multiple of the rotation time, so  you  can
190      synchronize cron scripts with it).  At the end of each rotation
191      time (here after 24 hours) a new log is started.</p>
192
193 <div class="example"><p><code>
194      CustomLog "|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400" common
195 </code></p></div>
196
197      <p>This creates the files /var/log/logfile.yyyy.mm.dd where
198      yyyy is the year, mm is the month, and dd is the day of the month.
199      Logging will switch to a new file every day at midnight, local time.</p>
200
201 <div class="example"><p><code>
202      CustomLog "|bin/rotatelogs /var/log/logfile 5M" common
203 </code></p></div>
204
205      <p>This configuration will rotate the logfile whenever it reaches
206      a size of 5 megabytes.</p>
207
208 <div class="example"><p><code>
209      ErrorLog "|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H_%M_%S 5M"
210 </code></p></div>
211      <p>This configuration will rotate the error logfile whenever it
212      reaches a size of 5 megabytes, and the suffix to the logfile name
213      will be created of the form
214      <code>errorlog.YYYY-mm-dd-HH_MM_SS</code>.</p>
215
216 <div class="example"><p><code>
217      CustomLog "|bin/rotatelogs -t /var/log/logfile 86400" common
218 </code></p></div>
219
220      <p>This creates the file /var/log/logfile, truncating the file at
221      startup and then truncating the file once per day. It is expected
222      in this scenario that a separate process (such as tail) would
223      process the file in real time.</p>
224
225 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
226 <div class="section">
227 <h2><a name="portability" id="portability">Portability</a></h2>
228
229 <p>The following logfile format string substitutions should be
230 supported by all <code>strftime(3)</code> implementations, see
231 the <code>strftime(3)</code> man page for library-specific
232 extensions.</p>
233
234 <table class="bordered"><tr><td><code>%A</code></td><td>full weekday name (localized)</td></tr>
235 <tr class="odd"><td><code>%a</code></td><td>3-character weekday name (localized)</td></tr>
236 <tr><td><code>%B</code></td><td>full month name (localized)</td></tr>
237 <tr class="odd"><td><code>%b</code></td><td>3-character month name (localized)</td></tr>
238 <tr><td><code>%c</code></td><td>date and time (localized)</td></tr>
239 <tr class="odd"><td><code>%d</code></td><td>2-digit day of month</td></tr>
240 <tr><td><code>%H</code></td><td>2-digit hour (24 hour clock)</td></tr>
241 <tr class="odd"><td><code>%I</code></td><td>2-digit hour (12 hour clock)</td></tr>
242 <tr><td><code>%j</code></td><td>3-digit day of year</td></tr>
243 <tr class="odd"><td><code>%M</code></td><td>2-digit minute</td></tr>
244 <tr><td><code>%m</code></td><td>2-digit month</td></tr>
245 <tr class="odd"><td><code>%p</code></td><td>am/pm of 12 hour clock (localized)</td></tr>
246 <tr><td><code>%S</code></td><td>2-digit second</td></tr>
247 <tr class="odd"><td><code>%U</code></td><td>2-digit week of year
248 (Sunday first day of week)</td></tr>
249 <tr><td><code>%W</code></td><td>2-digit week of year
250 (Monday first day of week)</td></tr>
251 <tr class="odd"><td><code>%w</code></td><td>1-digit weekday
252 (Sunday first day of week)</td></tr>
253 <tr><td><code>%X</code></td><td>time (localized)</td></tr>
254 <tr class="odd"><td><code>%x</code></td><td>date (localized)</td></tr>
255 <tr><td><code>%Y</code></td><td>4-digit year</td></tr>
256 <tr class="odd"><td><code>%y</code></td><td>2-digit year</td></tr>
257 <tr><td><code>%Z</code></td><td>time zone name</td></tr>
258 <tr class="odd"><td><code>%%</code></td><td>literal `%'</td></tr>
259 </table>
260
261 </div></div>
262 <div class="bottomlang">
263 <p><span>Available Languages: </span><a href="../en/programs/rotatelogs.html" title="English">&nbsp;en&nbsp;</a> |
264 <a href="../ko/programs/rotatelogs.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
265 <a href="../tr/programs/rotatelogs.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
266 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
267 <script type="text/javascript"><!--//--><![CDATA[//><!--
268 var comments_shortname = 'httpd';
269 var comments_identifier = 'http://httpd.apache.org/docs/trunk/programs/rotatelogs.html';
270 (function(w, d) {
271     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
272         d.write('<div id="comments_thread"><\/div>');
273         var s = d.createElement('script');
274         s.type = 'text/javascript';
275         s.async = true;
276         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
277         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
278     }
279     else {
280         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
281     }
282 })(window, document);
283 //--><!]]></script></div><div id="footer">
284 <p class="apache">Copyright 2016 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
285 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
286 if (typeof(prettyPrint) !== 'undefined') {
287     prettyPrint();
288 }
289 //--><!]]></script>
290 </body></html>