Logging

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(renamed tag to directive)
(migration)
Line 1: Line 1:
 
[[Category:Configuration]]
 
[[Category:Configuration]]
  
Resin Configuration is at http://www.caucho.com/resin-3.0/config/log.xtp
+
== Access logging ==
  
Resin's <access-log> configures the URL access logging.  Its <log> configures the [java.util.logging] output.  Both share much of the common configuration.
+
{{main|access-log}}
  
==See Also==
+
An access log is a log that 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.
  
[[Redirecting Standard Output]]
+
=== Examples ===
  
==rollover directives==
+
<!-- pre -->
 +
<access-log path="logs/access.log"
 +
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
 +
            rollover-period="1W"/>
 +
<!-- /pre -->
  
<[[access-log]]> shares the rollover configuration with the <log>.
 
  
{{:Log Rollover}}
+
== stdout-log and stderr-log ==
  
==archive-format and path-format==
+
{{main|stdout-log}}
 +
{{main|stderr-log}}
  
archive-format and path-format are two mutually exclusive methods for archiving logs.  path-format writes directly to the archive log, e.g. archive-2005-01-02.log.  archive-format first writes to a log specified by <em>path</em>, e.g. access.log and then copies the access.log to the archive name at rollover time.
+
The stdout-log and stderr-log directives capture and redirect the output of
 +
[[System.out]] and [[System.err]].
  
archive-format uses the [[Date Format Configuration]] and [[Period Configuration]] syntax, for example:
+
=== Examples ===
  
...
+
[[resin.conf]] configuration to capture [[Sysyem.out]] and [[System.err]]
<host id="www.foo.com">
+
output to log files.
    <access-log path-format="/var/www/log/%Y/%m/%d.access.log"
+
                rollover-period="1D"/>
+
    ...
+
</host>
+
...
+
  
The archive-format can use a *.gz or *.zip extension to indicate that the archived log should be compressed.  Currently, path-format cannot be compressed.
+
<!-- pre title="resin.conf" syntax="conf" -->
  
  <access-log path="log/access.log"
+
  &lt;resin xmlns="http://caucho.com/ns/resin"
            archive-path="/var/www/log/access.log.%Y%m%d.gz"
+
        xmlns:resin="http://caucho.com/ns/resin/core"&gt;
            rollover-period="1D"/>
+
 +
  &lt;stdout-log path='/var/log/foo/stdout.log'
 +
              rollover-period='1W'/>
 +
  &lt;stderr-log path='/var/log/foo/stderr.log'
 +
              rollover-period='1W'/>
 +
 
 +
  ...
  
==access-log ==
+
<!-- /pre -->
  
{{:access-log}}
+
== log ==
  
The <access-log> directive 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.
+
{{main|log}}
  
 +
Java programs (including Resin) can use the logging facilities included in the
 +
JDK.  Log messages have a ''name'' and and a ''level''.
  
<access-log path="logs/access.log"
+
Some [[Resin logging names]] have been documented.
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
+
            rollover-period="1W"/>
+
  
==access-log format directives==
+
=== Examples ===
  
{|
+
Capture ''finer'' logging and display it on the console, useful during
||code||meaning
+
development:
|-
+
||%b||content length
+
|-
+
||%h||remote IP address
+
|-
+
||%\{xxx}i||request header xxx
+
|-
+
||%\{xxx}o||response header xxx
+
|-
+
||%\{xxx}c||cookie value 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
+
|}
+
  
==<log>==
+
<!--  pre -->
  
The <log> directive configures [[java.util.logging]] outputIt can appear in any [[Environment]].
+
<resin>
 +
  ...
 +
  <log name="" level="finer" path="stdout:"/>
 +
  ...
 +
  </resin>
  
By convention, the name of a logger is the class of the Java file that's logging, e.g. "com.caucho.server.port.Port".
+
<!-- /pre -->
  
{|
+
== Rollover directives ==
||attribute||meaning||default
+
|-
+
||name||logging name||required
+
|-
+
||level||java.util.logging level||info
+
|-
+
||timestamp||a timestamp to be used for logging||none
+
|-
+
||use-parent-handlers||if true, also write to the parent||true
+
|-
+
||handler||add a custom handler||
+
|-
+
||formatter||add a custom formatter||
+
|-
+
||mbean-name||save in jmx||
+
|-
+
||path||output path (see above)||required
+
|-
+
||path-format||formatted path (see above)||
+
|-
+
||archive-format||format of the archive (see above)||
+
|-
+
||rollover-period||how often to rollover (see above)||
+
|-
+
||rollover-size||how large a file before rolling over (see above)||
+
|}
+
  
The timestamp uses the [[Date Format Configuration]] syntax.
+
{{main|Rollover}}
  
package com.foo;
+
Rollover directives indicate that log files should be rolled over to new names
+
at specified frequencies, breaking ever growing log files into manageable
import java.util.logging.Logger;
+
chunks.
+
public class Test {
+
  private static final Logger log
+
    = Logger.getLogger(Test.class.getName());
+
+
  public void doStuff()
+
  {
+
    log.fine("doing stuff");
+
  }
+
}
+
  
 +
== Archiving directives ==
  
<resin xmlns="http://caucho.com/ns/resin">
+
{{main|Archiving}}
  <log name="com.foo" level="fine" path="log/debug.log"
+
        timestamp="[%H:%M:%S] "/>
+
  ...
+
</resin>
+
  
Conventions on logging levels:
+
'''archive-format''' and '''path-format''' are two mutually exclusive methods
 +
for archiving logs.
  
{|
+
path-format specifies the name of a file to write the log to, and the name
||level||use
+
contains [[date format]]  escape sequences that are replaced with the current
|-
+
date and time.
||warning||fatal errors
+
|-
+
||info||information for a typical install
+
|-
+
||fine||debug information useful for users
+
|-
+
||finer||debug information useful for developers
+
|}
+
  
For example, level="fine" for "com.caucho" will give the information most generally useful for Resin uses, while level="finer" will add more information that's more detailed for the Caucho developerslevel="info" is infrequent, giving significant information like the server starting.
+
...
 +
<host id="www.foo.com">
 +
    <access-log path-format="/var/www/log/%Y/%m/%d.access.log"
 +
                rollover-period="1D"/>
 +
    ...
 +
  </host>
 +
...
  
Some [[Resin Logging Names]] have been documented.
+
archive-format first writes to a file specified by
 +
[[path]], and then copies the file to the archive name at rollover time.
 +
 
 +
The file specified wth archive-format contains [[date format]]
 +
escape sequences that are replaced with the current date and time.
 +
 
 +
archive-format can use a *.gz or *.zip extension to indicate that the
 +
archived log should be compressed.
 +
 
 +
<access-log path="log/access.log"
 +
            archive-path="/var/www/log/access.log.%Y%m%d.gz"
 +
            rollover-period="1D"/>
  
==stdout-log and stderr-log==
+
== See also==
  
Resin can redirect the output of System.out and System.err using the <stdout-log> and <stderr-log> configuration in any [[Environment]].  The <stdout-log> and <stderr-log> use the same configuration as the <log> for rollover and archive paths.
+
; [[Redirecting standard output]] :

Revision as of 23:22, 27 February 2006


Contents

Access logging

Main article: access-log

An access log is a log that 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.

Examples

<access-log path="logs/access.log"
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
            rollover-period="1W"/>


stdout-log and stderr-log

Main article: stdout-log
Main article: stderr-log

The stdout-log and stderr-log directives capture and redirect the output of System.out and System.err.

Examples

resin.conf configuration to capture Sysyem.out and System.err output to log files.


<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">

  <stdout-log path='/var/log/foo/stdout.log'
              rollover-period='1W'/>
  <stderr-log path='/var/log/foo/stderr.log'
              rollover-period='1W'/>
 
  ...


log

Main article: log

Java programs (including Resin) can use the logging facilities included in the JDK. Log messages have a name and and a level.

Some Resin logging names have been documented.

Examples

Capture finer logging and display it on the console, useful during development:


<resin>
  ...
  <log name="" level="finer" path="stdout:"/>
  ...
</resin>


Rollover directives

Main article: Rollover

Rollover directives indicate that log files should be rolled over to new names at specified frequencies, breaking ever growing log files into manageable chunks.

Archiving directives

Main article: Archiving

archive-format and path-format are two mutually exclusive methods for archiving logs.

path-format specifies the name of a file to write the log to, and the name contains date format escape sequences that are replaced with the current date and time.

...
<host id="www.foo.com">
   <access-log path-format="/var/www/log/%Y/%m/%d.access.log"
               rollover-period="1D"/>
   ... 
</host>
...

archive-format first writes to a file specified by path, and then copies the file to the archive name at rollover time.

The file specified wth archive-format contains date format escape sequences that are replaced with the current date and time.

archive-format can use a *.gz or *.zip extension to indicate that the archived log should be compressed.

<access-log path="log/access.log"
            archive-path="/var/www/log/access.log.%Y%m%d.gz"
            rollover-period="1D"/>

See also

Redirecting standard output 
Personal tools