Access-log

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
 
(added %l and {xxx} to %n argument (after reading the source code))
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Configuration]]
+
[[Category:Directives]]
  
The <access-log> tag controls the information Resin prints with each request.   It can appear in any of the [[Server Configuration|<server>]], [[Host Configuration|<host>]], or <[[web-app]] environments.
+
An '''access-log''' receives output describing each request received by
 +
the server. It is commonly used in conjunction with analyzing tools to
 +
determine statistics and patterns of use for a website.
  
 +
The access-log directive controls the information Resin writes with each
 +
request.  It can appear in any [[environment]] (i.e. within a [[server]],
 +
[[host]], or [[web-app]]).
  
<access-log path="logs/access.log"
+
== directives ==
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
+
            rollover-period="1W"/>
+
 
+
== configuration tags ==
+
  
 
{|
 
{|
!code||meaning||default
+
!directive||meaning||default
 +
|-
 +
||[[auto-flush]]||flush after each log entry||false
 +
|-
 +
||[[path]]
 +
||output path for the stream
 +
||either <tt>path-format</tt> or <tt>path</tt> is required
 +
|-
 +
||[[path-format]]
 +
||the name of a file to write the log to, [[date format]] escape sequences are replaced with the current date and time
 +
||either <tt>path</tt> or <tt>path-format</tt> is required
 +
|-
 +
||[[rollover-period]]
 +
||how often to rollover the log.  Specify a [[period]] in days (15D), weeks (2W), months (1M), or hours (1h)
 +
||none
 
|-
 
|-
||auto-flush||flush after each log entry||false
+
||[[rollover-size]]
 +
||maximum size of the file before a rollover occurs.  Specify a [[size]] in bytes (50000), kb (128kb), or megabytes (10mb)
 +
||1mb
 
|-
 
|-
||any [[rollover-log]] entry
+
||[[archive-format]]
 +
||the format for the archive filename when a rollover occurs
 +
|| ''path'' + ".%Y%m%d" or ''path'' + ".%Y%m%d.%H" if <tt>rollover-period</tt> &lt; 1 day
 
|}
 
|}
  
==access-log format tags==
+
== format ==
  
 
{|
 
{|
||code||meaning
+
!code||meaning
 
|-
 
|-
 
||%b||content length
 
||%b||content length
Line 33: Line 52:
 
||%\{xxx}c||cookie value xxx
 
||%\{xxx}c||cookie value xxx
 
|-
 
|-
||%n||request attribute
+
||%\{xxx}n||request attribute
 
|-
 
|-
 
||%r||request URL
 
||%r||request URL
Line 48: Line 67:
 
|-
 
|-
 
||%U||request URL
 
||%U||request URL
 +
|-
 +
||%l||Not used. Recognized but always results in "-"
 
|}
 
|}
 +
 +
== Custom log handlers ==
 +
 +
resin:type allows for custom logging. Applications can extend a custom class
 +
from {{javadoc|com.caucho.http.log.AccessLog}}. [[Bean-style initialization]]
 +
can be used to set bean parameters in the custom class.
 +
 +
The followng example shows the configuration for a theoretical
 +
<tt>test.MyLog</tt> class that extends
 +
{{javadoc|com.caucho.http.log.AccessLog}}.  Since the configuration is
 +
contained within a host, the <tt>test/Mylog.class</tt> must be available in the
 +
[[class-loader]] for the host.
 +
 +
<!-- pre -->
 +
...
 +
<host>
 +
  <access-log resin:type='test.MyLog'>
 +
              path='$server-root/foo/error.log'
 +
              rollover-period='1W'>
 +
    <init>
 +
      <foo>bar</foo>
 +
    </init>
 +
  </access-log>
 +
  ...
 +
<!-- /pre -->
 +
 +
== See also ==
 +
 +
; [[Logging]] : A general overview of logging facilities in Resin

Latest revision as of 01:24, 15 October 2008


An access-log receives output describing each request received by the server. It is commonly used in conjunction with analyzing tools to determine statistics and patterns of use for a website.

The access-log directive controls the information Resin writes with each request. It can appear in any environment (i.e. within a server, host, or web-app).

Contents

directives

directive meaning default
auto-flush flush after each log entry false
path output path for the stream either path-format or path is required
path-format the name of a file to write the log to, date format escape sequences are replaced with the current date and time either path or path-format is required
rollover-period how often to rollover the log. Specify a period in days (15D), weeks (2W), months (1M), or hours (1h) none
rollover-size maximum size of the file before a rollover occurs. Specify a size in bytes (50000), kb (128kb), or megabytes (10mb) 1mb
archive-format the format for the archive filename when a rollover occurs path + ".%Y%m%d" or path + ".%Y%m%d.%H" if rollover-period < 1 day

format

code meaning
%b content length
%h remote IP address
%\{xxx}i request header xxx
%\{xxx}o response header xxx
%\{xxx}c cookie value xxx
%\{xxx}n request attribute
%r request URL
%s status code
%\{xxx}t date with optional time format
%T time of request in seconds
%D time of request in microseconds (3.0.15)
%u remote user
%U request URL
%l Not used. Recognized but always results in "-"

Custom log handlers

resin:type allows for custom logging. Applications can extend a custom class from com.caucho.http.log.AccessLog. Bean-style initialization can be used to set bean parameters in the custom class.

The followng example shows the configuration for a theoretical test.MyLog class that extends com.caucho.http.log.AccessLog. Since the configuration is contained within a host, the test/Mylog.class must be available in the class-loader for the host.

...
<host>
  <access-log resin:type='test.MyLog'>
             path='$server-root/foo/error.log'
             rollover-period='1W'>
    <init>
      <foo>bar</foo>
    </init>
  </access-log>
  ...

See also

Logging 
A general overview of logging facilities in Resin
Personal tools