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 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 5 This file is generated from xml source: DO NOT EDIT 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 --> 8<title>mod_log_config - Apache HTTP Server</title> 9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 11<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" /> 12<script src="/style/scripts/prettify.js" type="text/javascript"> 13</script> 14 15<link href="/images/favicon.ico" rel="shortcut icon" /></head> 16<body> 17<div id="page-header"> 18<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.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> 19<p class="apache">Apache HTTP Server Version 2.2</p> 20<img alt="" src="/images/feather.gif" /></div> 21<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div> 22<div id="path"> 23<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div> 24<div id="page-content"> 25<div id="preamble"><h1>Apache Module mod_log_config</h1> 26<div class="toplang"> 27<p><span>Available Languages: </span><a href="/en/mod/mod_log_config.html" title="English"> en </a> | 28<a href="/ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 29<a href="/ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 30<a href="/tr/mod/mod_log_config.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p> 31</div> 32<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Logging of the requests made to the server</td></tr> 33<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr> 34<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>log_config_module</td></tr> 35<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_log_config.c</td></tr></table> 36<h3>Summary</h3> 37 38 <p>This module provides for flexible logging of client 39 requests. Logs are written in a customizable format, and may be 40 written directly to a file, or to an external program. 41 Conditional logging is provided so that individual requests may 42 be included or excluded from the logs based on characteristics 43 of the request.</p> 44 45 <p>Three directives are provided by this module: 46 <code class="directive"><a href="#transferlog">TransferLog</a></code> to create 47 a log file, <code class="directive"><a href="#logformat">LogFormat</a></code> 48 to set a custom format, and <code class="directive"><a href="#customlog">CustomLog</a></code> to define a log file and format in one 49 step. The <code class="directive">TransferLog</code> and <code class="directive">CustomLog</code> directives can be used multiple times in each 50 server to cause each request to be logged to multiple files.</p> 51</div> 52<div id="quickview"><h3 class="directives">Directives</h3> 53<ul id="toc"> 54<li><img alt="" src="/images/down.gif" /> <a href="#bufferedlogs">BufferedLogs</a></li> 55<li><img alt="" src="/images/down.gif" /> <a href="#cookielog">CookieLog</a></li> 56<li><img alt="" src="/images/down.gif" /> <a href="#customlog">CustomLog</a></li> 57<li><img alt="" src="/images/down.gif" /> <a href="#logformat">LogFormat</a></li> 58<li><img alt="" src="/images/down.gif" /> <a href="#transferlog">TransferLog</a></li> 59</ul> 60<h3>Topics</h3> 61<ul id="topics"> 62<li><img alt="" src="/images/down.gif" /> <a href="#formats">Custom Log Formats</a></li> 63<li><img alt="" src="/images/down.gif" /> <a href="#security">Security Considerations</a></li> 64</ul><h3>See also</h3> 65<ul class="seealso"> 66<li><a href="/logs.html">Apache Log Files</a></li> 67</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 68<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 69<div class="section"> 70<h2><a name="formats" id="formats">Custom Log Formats</a></h2> 71 72 <p>The format argument to the <code class="directive"><a href="#logformat">LogFormat</a></code> and <code class="directive"><a href="#customlog">CustomLog</a></code> directives is a string. This string is 73 used to log each request to the log file. It can contain literal 74 characters copied into the log files and the C-style control 75 characters "\n" and "\t" to represent new-lines and tabs. 76 Literal quotes and backslashes should be escaped with 77 backslashes.</p> 78 79 <p>The characteristics of the request itself are logged by 80 placing "<code>%</code>" directives in the format string, which are 81 replaced in the log file by the values as follows:</p> 82 83 <table class="bordered"><tr class="header"><th>Format String</th> 84 <th>Description</th></tr> 85<tr><td><code>%%</code></td> 86 <td>The percent sign</td></tr> 87<tr class="odd"><td><code>%a</code></td> 88 <td>Remote IP-address</td></tr> 89<tr><td><code>%A</code></td> 90 <td>Local IP-address</td></tr> 91<tr class="odd"><td><code>%B</code></td> 92 <td>Size of response in bytes, excluding HTTP headers.</td></tr> 93<tr><td><code>%b</code></td> 94 <td>Size of response in bytes, excluding HTTP headers. In CLF format, <em>i.e.</em> 95 a '<code>-</code>' rather than a 0 when no bytes are sent.</td></tr> 96<tr class="odd"><td><code>%{<var>Foobar</var>}C</code></td> 97 <td>The contents of cookie <var>Foobar</var> in the request sent 98 to the server. Only version 0 cookies are fully supported.</td></tr> 99<tr><td><code>%D</code></td> 100 <td>The time taken to serve the request, in microseconds.</td></tr> 101<tr class="odd"><td><code>%{<var>FOOBAR</var>}e</code></td> 102 <td>The contents of the environment variable 103 <var>FOOBAR</var></td></tr> 104<tr><td><code>%f</code></td> 105 <td>Filename</td></tr> 106<tr class="odd"><td><code>%h</code></td> 107 <td>Remote host</td></tr> 108<tr><td><code>%H</code></td> 109 <td>The request protocol</td></tr> 110<tr class="odd"><td><code>%{<var>Foobar</var>}i</code></td> 111 <td>The contents of <code><var>Foobar</var>:</code> header line(s) 112 in the request sent to the server. Changes made by other 113 modules (e.g. <code class="module"><a href="/mod/mod_headers.html">mod_headers</a></code>) affect this. If you're 114 interested in what the request header was prior to when most 115 modules would have modified it, use <code class="module"><a href="/mod/mod_setenvif.html">mod_setenvif</a></code> 116 to copy the header into an internal environment variable and log 117 that value with the <code>%{<var>VARNAME</var>}e</code> described 118 above. 119 </td></tr> 120<tr><td><code>%k</code></td> 121 <td>Number of keepalive requests handled on this connection. Interesting if 122 <code class="directive"><a href="/mod/core.html#keepalive">KeepAlive</a></code> is being used, so that, 123 for example, a '1' means the first keepalive request after the initial 124 one, '2' the second, etc...; 125 otherwise this is always 0 (indicating the initial request). 126 Available in versions 2.2.11 and later.</td></tr> 127<tr class="odd"><td><code>%l</code></td> 128 <td>Remote logname (from identd, if supplied). This will return a 129 dash unless <code class="module"><a href="/mod/mod_ident.html">mod_ident</a></code> is present and <code class="directive"><a href="/mod/mod_ident.html#identitycheck">IdentityCheck</a></code> is set 130 <code>On</code>.</td></tr> 131<tr><td><code>%m</code></td> 132 <td>The request method</td></tr> 133<tr class="odd"><td><code>%{<var>Foobar</var>}n</code></td> 134 <td>The contents of note <var>Foobar</var> from another 135 module.</td></tr> 136<tr><td><code>%{<var>Foobar</var>}o</code></td> 137 <td>The contents of <code><var>Foobar</var>:</code> header line(s) 138 in the reply.</td></tr> 139<tr class="odd"><td><code>%p</code></td> 140 <td>The canonical port of the server serving the request</td></tr> 141<tr><td><code>%{<var>format</var>}p</code></td> 142 <td>The canonical port of the server serving the request or the 143 server's actual port or the client's actual port. Valid formats 144 are <code>canonical</code>, <code>local</code>, or <code>remote</code>. 145 </td></tr> 146<tr class="odd"><td><code>%P</code></td> 147 <td>The process ID of the child that serviced the request.</td></tr> 148<tr><td><code>%{<var>format</var>}P</code></td> 149 <td>The process ID or thread id of the child that serviced the 150 request. Valid formats are <code>pid</code>, <code>tid</code>, 151 and <code>hextid</code>. <code>hextid</code> requires APR 1.2.0 or 152 higher. 153 </td></tr> 154<tr class="odd"><td><code>%q</code></td> 155 <td>The query string (prepended with a <code>?</code> if a query 156 string exists, otherwise an empty string)</td></tr> 157<tr><td><code>%r</code></td> 158 <td>First line of request</td></tr> 159<tr class="odd"><td><code>%R</code></td> 160 <td>The handler generating the response (if any).</td></tr> 161<tr><td><code>%s</code></td> 162 <td>Status. For requests that got internally redirected, this is 163 the status of the *original* request --- <code>%>s</code> 164 for the last.</td></tr> 165<tr class="odd"><td><code>%t</code></td> 166 <td>Time the request was received (standard english 167 format)</td></tr> 168<tr><td><code>%{<var>format</var>}t</code></td> 169 <td>The time, in the form given by format, which should be in 170 <code>strftime(3)</code> format. (potentially localized)</td></tr> 171<tr class="odd"><td><code>%T</code></td> 172 <td>The time taken to serve the request, in seconds.</td></tr> 173<tr><td><code>%u</code></td> 174 <td>Remote user (from auth; may be bogus if return status 175 (<code>%s</code>) is 401)</td></tr> 176<tr class="odd"><td><code>%U</code></td> 177 <td>The URL path requested, not including any query string.</td></tr> 178<tr><td><code>%v</code></td> 179 <td>The canonical <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> 180 of the server serving the request.</td></tr> 181<tr class="odd"><td><code>%V</code></td> 182 <td>The server name according to the <code class="directive"><a href="/mod/core.html#usecanonicalname">UseCanonicalName</a></code> setting.</td></tr> 183<tr><td><code>%X</code></td> 184 <td>Connection status when response is completed: 185 186 <table> 187 188 <tr><td><code>X</code> =</td> 189 <td>connection aborted before the response completed.</td></tr> 190 <tr><td><code>+</code> =</td> 191 <td>connection may be kept alive after the response is 192 sent.</td></tr> 193 <tr><td><code>-</code> = </td> 194 <td>connection will be closed after the response is 195 sent.</td></tr> 196 </table> 197 198 <p>(This directive was <code>%c</code> in late versions of Apache 199 1.3, but this conflicted with the historical ssl 200 <code>%{<var>var</var>}c</code> syntax.)</p></td></tr> 201<tr class="odd"><td><code>%I</code></td> 202 <td>Bytes received, including request and headers, cannot be zero. 203 You need to enable <code class="module"><a href="/mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr> 204<tr><td><code>%O</code></td> 205 <td>Bytes sent, including headers, cannot be zero. You need to 206 enable <code class="module"><a href="/mod/mod_logio.html">mod_logio</a></code> to use this.</td></tr> 207</table> 208 209 <h3><a name="modifiers" id="modifiers">Modifiers</a></h3> 210 211 <p>Particular items can be restricted to print only for 212 responses with specific HTTP status codes by placing a 213 comma-separated list of status codes immediately following the 214 "%". For example, <code>"%400,501{User-agent}i"</code> logs 215 <code>User-agent</code> on 400 errors and 501 errors only. For 216 other status codes, the literal string <code>"-"</code> will be 217 logged. The status code list may be preceded by a 218 "<code>!</code>" to indicate negation: 219 <code>"%!200,304,302{Referer}i"</code> logs <code>Referer</code> 220 on all requests that do <em>not</em> return one of the three 221 specified codes.</p> 222 223 <p>The modifiers "<" and ">" can be used for requests that 224 have been internally redirected to choose whether the original 225 or final (respectively) request should be consulted. By 226 default, the <code>%</code> directives <code>%s, %U, %T, 227 %D,</code> and <code>%r</code> look at the original request 228 while all others look at the final request. So for example, 229 <code>%>s</code> can be used to record the final status of 230 the request and <code>%<u</code> can be used to record the 231 original authenticated user on a request that is internally 232 redirected to an unauthenticated resource.</p> 233 234 235 236 <h3><a name="format-notes" id="format-notes">Some Notes</a></h3> 237 238 <p>For security reasons, starting with version 2.0.46, 239 non-printable and other special characters in <code>%r</code>, 240 <code>%i</code> and <code>%o</code> are escaped using 241 <code>\x<var>hh</var></code> sequences, where <var>hh</var> 242 stands for the hexadecimal representation of the raw 243 byte. Exceptions from this rule are <code>"</code> and 244 <code>\</code>, which are escaped by prepending a backslash, and 245 all whitespace characters, which are written in their C-style 246 notation (<code>\n</code>, <code>\t</code>, etc). In versions 247 prior to 2.0.46, no escaping was performed on these strings so 248 you had to be quite careful when dealing with raw log files.</p> 249 250 <p>In httpd 2.0, unlike 1.3, the <code>%b</code> and 251 <code>%B</code> format strings do not represent the number of 252 bytes sent to the client, but simply the size in bytes of the 253 HTTP response (which will differ, for instance, if the 254 connection is aborted, or if SSL is used). The <code>%O</code> 255 format provided by <code class="module"><a href="/mod/mod_logio.html">mod_logio</a></code> will log the 256 actual number of bytes sent over the network.</p> 257 258 <p>Note: <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> is implemented as a 259 quick-handler and not as a standard handler. Therefore, the 260 <code>%R</code> format string will not return any handler 261 information when content caching is involved.</p> 262 263 264 265 <h3><a name="examples" id="examples">Examples</a></h3> 266 267 <p>Some commonly used log format strings are:</p> 268 269 <dl> 270 <dt>Common Log Format (CLF)</dt> 271 <dd><code>"%h %l %u %t \"%r\" %>s %b"</code></dd> 272 273 <dt>Common Log Format with Virtual Host</dt> 274 <dd><code>"%v %h %l %u %t \"%r\" %>s %b"</code></dd> 275 276 <dt>NCSA extended/combined log format</dt> 277 <dd><code>"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" 278 \"%{User-agent}i\""</code></dd> 279 280 <dt>Referer log format</dt> 281 <dd><code>"%{Referer}i -> %U"</code></dd> 282 283 <dt>Agent (Browser) log format</dt> 284 <dd><code>"%{User-agent}i"</code></dd> 285 </dl> 286 287</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 288<div class="section"> 289<h2><a name="security" id="security">Security Considerations</a></h2> 290 <p>See the <a href="/misc/security_tips.html#serverroot">security tips</a> 291 document for details on why your security could be compromised 292 if the directory where logfiles are stored is writable by 293 anyone other than the user that starts the server.</p> 294</div> 295<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 296<div class="directive-section"><h2><a name="BufferedLogs" id="BufferedLogs">BufferedLogs</a> <a name="bufferedlogs" id="bufferedlogs">Directive</a></h2> 297<table class="directive"> 298<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Buffer log entries in memory before writing to disk</td></tr> 299<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>BufferedLogs On|Off</code></td></tr> 300<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>BufferedLogs Off</code></td></tr> 301<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 302<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 303<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr> 304<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in versions 2.0.41 and later.</td></tr> 305</table> 306 <p>The <code class="directive">BufferedLogs</code> directive causes 307 <code class="module"><a href="/mod/mod_log_config.html">mod_log_config</a></code> to store several log entries in 308 memory and write them together to disk, rather than writing them 309 after each request. On some systems, this may result in more 310 efficient disk access and hence higher performance. It may be 311 set only once for the entire server; it cannot be configured 312 per virtual-host.</p> 313 314 <div class="note">This directive is experimental and should be used with 315 caution.</div> 316 317</div> 318<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 319<div class="directive-section"><h2><a name="CookieLog" id="CookieLog">CookieLog</a> <a name="cookielog" id="cookielog">Directive</a></h2> 320<table class="directive"> 321<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename for the logging of cookies</td></tr> 322<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CookieLog <var>filename</var></code></td></tr> 323<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 324<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 325<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr> 326<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>This directive is deprecated.</td></tr> 327</table> 328 <p>The <code class="directive">CookieLog</code> directive sets the 329 filename for logging of cookies. The filename is relative to the 330 <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code>. This directive is 331 included only for compatibility with <code>mod_cookies</code>, 332 and is deprecated.</p> 333 334</div> 335<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 336<div class="directive-section"><h2><a name="CustomLog" id="CustomLog">CustomLog</a> <a name="customlog" id="customlog">Directive</a></h2> 337<table class="directive"> 338<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sets filename and format of log file</td></tr> 339<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CustomLog <var>file</var>|<var>pipe</var> 340<var>format</var>|<var>nickname</var> 341[env=[!]<var>environment-variable</var>]</code></td></tr> 342<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 343<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 344<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr> 345</table> 346 <p>The <code class="directive">CustomLog</code> directive is used to 347 log requests to the server. A log format is specified, and the 348 logging can optionally be made conditional on request 349 characteristics using environment variables.</p> 350 351 <p>The first argument, which specifies the location to which 352 the logs will be written, can take one of the following two 353 types of values:</p> 354 355 <dl> 356 <dt><var>file</var></dt> 357 <dd>A filename, relative to the <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code>.</dd> 358 359 <dt><var>pipe</var></dt> 360 <dd>The pipe character "<code>|</code>", followed by the path 361 to a program to receive the log information on its standard 362 input. See the notes on <a href="/logs.html#piped">piped logs</a> 363 for more information. 364 365 <div class="warning"><h3>Security:</h3> 366 <p>If a program is used, then it will be run as the user who 367 started <code class="program"><a href="/programs/httpd.html">httpd</a></code>. This will be root if the server was 368 started by root; be sure that the program is secure.</p> 369 </div> 370 <div class="warning"><h3>Note</h3> 371 <p>When entering a file path on non-Unix platforms, care should be taken 372 to make sure that only forward slashed are used even though the platform 373 may allow the use of back slashes. In general it is a good idea to always 374 use forward slashes throughout the configuration files.</p> 375 </div></dd> 376 </dl> 377 378 <p>The second argument specifies what will be written to the 379 log file. It can specify either a <var>nickname</var> defined by 380 a previous <code class="directive"><a href="#logformat">LogFormat</a></code> 381 directive, or it can be an explicit <var>format</var> string as 382 described in the <a href="#formats">log formats</a> section.</p> 383 384 <p>For example, the following two sets of directives have 385 exactly the same effect:</p> 386 387 <div class="example"><p><code> 388 # CustomLog with format nickname<br /> 389 LogFormat "%h %l %u %t \"%r\" %>s %b" common<br /> 390 CustomLog logs/access_log common<br /> 391 <br /> 392 # CustomLog with explicit format string<br /> 393 CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b" 394 </code></p></div> 395 396 <p>The third argument is optional and controls whether or 397 not to log a particular request based on the 398 presence or absence of a particular variable in the server 399 environment. If the specified <a href="/env.html">environment 400 variable</a> is set for the request (or is not set, in the case 401 of a '<code>env=!<var>name</var></code>' clause), then the 402 request will be logged.</p> 403 404 <p>Environment variables can be set on a per-request 405 basis using the <code class="module"><a href="/mod/mod_setenvif.html">mod_setenvif</a></code> 406 and/or <code class="module"><a href="/mod/mod_rewrite.html">mod_rewrite</a></code> modules. For 407 example, if you want to record requests for all GIF 408 images on your server in a separate logfile but not in your main 409 log, you can use:</p> 410 411 <div class="example"><p><code> 412 SetEnvIf Request_URI \.gif$ gif-image<br /> 413 CustomLog gif-requests.log common env=gif-image<br /> 414 CustomLog nongif-requests.log common env=!gif-image 415 </code></p></div> 416 417 <p>Or, to reproduce the behavior of the old RefererIgnore 418 directive, you might use the following:</p> 419 420 <div class="example"><p><code> 421 SetEnvIf Referer example\.com localreferer<br /> 422 CustomLog referer.log referer env=!localreferer 423 </code></p></div> 424 425</div> 426<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 427<div class="directive-section"><h2><a name="LogFormat" id="LogFormat">LogFormat</a> <a name="logformat" id="logformat">Directive</a></h2> 428<table class="directive"> 429<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Describes a format for use in a log file</td></tr> 430<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>LogFormat <var>format</var>|<var>nickname</var> 431[<var>nickname</var>]</code></td></tr> 432<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>LogFormat "%h %l %u %t \"%r\" %>s %b"</code></td></tr> 433<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 434<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 435<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr> 436</table> 437 <p>This directive specifies the format of the access log 438 file.</p> 439 440 <p>The <code class="directive">LogFormat</code> directive can take one of two 441 forms. In the first form, where only one argument is specified, 442 this directive sets the log format which will be used by logs 443 specified in subsequent <code class="directive">TransferLog</code> 444 directives. The single argument can specify an explicit 445 <var>format</var> as discussed in the <a href="#formats">custom log 446 formats</a> section above. Alternatively, it can use a 447 <var>nickname</var> to refer to a log format defined in a 448 previous <code class="directive">LogFormat</code> directive as described 449 below.</p> 450 451 <p>The second form of the <code class="directive">LogFormat</code> 452 directive associates an explicit <var>format</var> with a 453 <var>nickname</var>. This <var>nickname</var> can then be used in 454 subsequent <code class="directive">LogFormat</code> or 455 <code class="directive"><a href="#customlog">CustomLog</a></code> directives 456 rather than repeating the entire format string. A 457 <code class="directive">LogFormat</code> directive that defines a nickname 458 <strong>does nothing else</strong> -- that is, it <em>only</em> 459 defines the nickname, it doesn't actually apply the format and make 460 it the default. Therefore, it will not affect subsequent 461 <code class="directive"><a href="#transferlog">TransferLog</a></code> directives. 462 In addition, <code class="directive">LogFormat</code> cannot use one nickname 463 to define another nickname. Note that the nickname should not contain 464 percent signs (<code>%</code>).</p> 465 466 <div class="example"><h3>Example</h3><p><code> 467 LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common 468 </code></p></div> 469 470</div> 471<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 472<div class="directive-section"><h2><a name="TransferLog" id="TransferLog">TransferLog</a> <a name="transferlog" id="transferlog">Directive</a></h2> 473<table class="directive"> 474<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Specify location of a log file</td></tr> 475<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>TransferLog <var>file</var>|<var>pipe</var></code></td></tr> 476<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 477<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr> 478<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_log_config</td></tr> 479</table> 480 <p>This directive has exactly the same arguments and effect as 481 the <code class="directive"><a href="#customlog">CustomLog</a></code> 482 directive, with the exception that it does not allow the log format 483 to be specified explicitly or for conditional logging of requests. 484 Instead, the log format is determined by the most recently specified 485 <code class="directive"><a href="#logformat">LogFormat</a></code> directive 486 which does not define a nickname. Common Log Format is used if no 487 other format has been specified.</p> 488 489 <div class="example"><h3>Example</h3><p><code> 490 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""<br /> 491 TransferLog logs/access_log 492 </code></p></div> 493 494</div> 495</div> 496<div class="bottomlang"> 497<p><span>Available Languages: </span><a href="/en/mod/mod_log_config.html" title="English"> en </a> | 498<a href="/ja/mod/mod_log_config.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 499<a href="/ko/mod/mod_log_config.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 500<a href="/tr/mod/mod_log_config.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p> 501</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&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> 502<script type="text/javascript"><!--//--><![CDATA[//><!-- 503var comments_shortname = 'httpd'; 504var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_log_config.html'; 505(function(w, d) { 506 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 507 d.write('<div id="comments_thread"><\/div>'); 508 var s = d.createElement('script'); 509 s.type = 'text/javascript'; 510 s.async = true; 511 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 512 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 513 } 514 else { 515 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 516 } 517})(window, document); 518//--><!]]></script></div><div id="footer"> 519<p class="apache">Copyright 2013 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> 520<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.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[//><!-- 521if (typeof(prettyPrint) !== 'undefined') { 522 prettyPrint(); 523} 524//--><!]]></script> 525</body></html>