Project

General

Profile

Mod accesslog » History » Revision 28

Revision 27 (stbuehler, 2013-08-30 16:08) → Revision 28/48 (gstrauss, 2016-07-13 04:15)

h1. Accesslog 

 *Module: mod_accesslog* 

 {{>toc}} 

 h2. Description 

 CLF like by default, flexible like apache 


 h2. Options 

 * accesslog.use-syslog 
   send the accesslog to syslog 
  
   Default: disabled 

 * accesslog.syslog-level (since 1.4.33) 
   severity level for syslog logging 

   Default: 6 (info) 

   See http://en.wikipedia.org/wiki/Syslog#Severity_levels for numerical values 

 * accesslog.filename 
   name of the file where the accesslog should be written to if syslog is not used. 
  
   if the name starts with a '|' the rest of the name is taken as the name of a process which will be spawned and will get the output 
  
   e.g.:<pre> 
 accesslog.filename = "/var/log/lighttpd.log" 

 $HTTP["host"] == "mail.example.org" { 
   accesslog.filename = "|/usr/bin/cronolog" 
 }</pre> 

   if you have multiple workers on 1.4.x (now, the current version) and want all access logs to be written (without that, only one worker will write logs), use accesslog.filename = "\|/usr/sbin/cronolog.." 
    
   Default: disabled 

 * accesslog.format 
   the format of the logfile 
  
   |_. Option |_. Description                              | 
   | %%         | a percent sign                             | 
   | %h         | name or address of remote-host             | 
   | %l         | ident name (not supported)                 | 
   | %u         | authenticated user                         | 
   | %t         | timestamp of the end-time of the request | 
   | %{...}t    | timestamp of the end-time of the request | (supported in 1.4.40) | 
   | %r         | request-line                               | 
   | %s         | status code                                | 
   | %b         | bytes sent for the body                    | 
   | %i         | HTTP-header field                          | 
   | %a         | remote address                             | (supported in 1.4.40) | 
   | %A         | local address                              | (supported in 1.4.40) | 
   | %B         | same as %b                                 | 
   | %C         | cookie field                               (not supported)               | (supported in 1.4.40) | 
   | %D         | time used in ms                            (not supported)            | (supported in 1.4.40) | 
   | %e         | environment                                | 
   | %f         | physical filename                          | 
   | %H         | request protocol (HTTP/1.0, ...)           | 
   | %k         | num keepalives                             | (supported in 1.4.40) | 
   | %m         | request method (GET, POST, ...)            | 
   | %n         | (not supported)                            | 
   | %o         | response header                            `response header`_                         | 
   | %p         | server port                                | 
   | %P         | (not supported)                            | 
   | %q         | query string                               | 
   | %T         | time used in seconds                       | 
   | %{UNIT}T | time used in UNIT (s, ms, us, or ns)       | (supported in 1.4.40) | 
   | %U         | request URL                                | 
   | %v         | server-name                                | 
   | %V         | HTTP request host name                     | 
   | %X         | connection status                          | 
   | %I         | bytes incoming                             incomming                            | 
   | %O         | bytes outgoing                             | 
  
   If %s is written %>s or %<s the < and the > are ignored. They are supported for compatibility with apache.  

   %h will always return the IP address of the host, never the name. This makes it equivalent to %a. %a, which is not implemented. 

   %a, %A, %{name}C, %D, %k, %{...}t, %{...}T %D are implemented in lighttpd 1.4.40 all unimplemented as of 1.4.26 and later. 1.5.0-r2700 
  
   %i and %o expect the name of the field which should be written in curly brackets. 

   %q is not prepended with '?', unlike Apache 

   %{StrFTime format string}t is supported since 1.4.24. 

   %t does not work the same way it works in Apache (where the start of the request is recorded). Instead it shows the time the request actually got delivered. This is done due to performance reasons. For most users this does not matter as usually requests don't take long to get processed.    Use %{begin:...}t for In case you want to find out the time at start of request. the request was started add the %T option to your log-string and subtract it's value from the time shown by %t. 
 </pre> 
  
 In lighttpd version 1.3.16, the default format is: 

 <pre> 
     accesslog.format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
 </pre> 

   Default: CLF compatible output. 

 In lighttpd versions 1.4.13-1.4.20, the default setting is: 

 <pre> 
     accesslog.format = "%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
 </pre> 

 The difference between Apache's CLF is the second field changes from ``%l`` to ``%V``. 

 h2. Response Header 


 The accesslog module provides a special way to log content from the 
 application in a accesslog file. It can be used to log the session id into a 
 logfile. 

 If you want to log it into the accesslog just specify the field-name within 
 a %{...}o like :: 

 <pre> 
   accesslog.format = "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-LIGHTTPD-SID}o\"" 
 </pre> 
  
 The prefix ``X-LIGHTTPD-`` is special as every response header starting with 
 this prefix is assumed to be special for lighttpd and won't be sent out 
 to the client.  

 An example the use this functionality is provided below: :: 

 <pre> 
   <?php 
  
   session_start(); 
  
   header("X-LIGHTTPD-SID: ".session_id()); 
  
   ?> 
   TEST 
 </pre> 



 ---- 
 Note: If you log to a pipe and have lighty chrooted the user running lighty will need access to “/bin/sh”.