Access-log

From CauchoWiki

Jump to: navigation, search


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

[edit] directives

directivemeaningdefault
auto-flushflush after each log entryfalse
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

[edit] format

codemeaning
%bcontent length
%hremote IP address
%\{xxx}irequest header xxx
%\{xxx}oresponse header xxx
%\{xxx}ccookie value xxx
%nrequest attribute
%rrequest URL
%sstatus code
%\{xxx}tdate with optional time format
%Ttime of request in seconds
%Dtime of request in microseconds (3.0.15)
%uremote user
%Urequest URL

[edit] 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>
  ...

[edit] See also

Logging 
A general overview of logging facilities in Resin
Personal tools