Logging

From Resin 3.0

Revision as of 17:14, 3 January 2006 by Ferg (Talk | contribs)
Jump to: navigation, search


Resin Configuration is at http://www.caucho.com/resin-3.0/config/log.xtp

Resin's <access-log> configures the URL access logging. Its <log> configures the [java.util.logging] output. Both share much of the common configuration.

Contents

See Also

Redirecting Standard Output

rollover tags

<access-log> shares the rollover configuration with the <log>.

Log Rollover

archive-format and path-format

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 path, e.g. access.log and then copies the access.log to the archive name at rollover time.

archive-format uses the Date Format Configuration and Period Configuration syntax, for example:

...
<host id="www.foo.com">
   <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.

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

access-log

The <access-log> tag controls the information Resin prints with each request. It can appear in any of the <server>, <host>, or <web-app environments.


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

access-log format tags

code meaning
%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>

The <log> tag configures java.util.logging output. It can appear in any Environment.

By convention, the name of a logger is the class of the Java file that's logging, e.g. "com.caucho.server.port.Port".

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.

package com.foo;

import java.util.logging.Logger;

public class Test {
  private static final Logger log
    = Logger.getLogger(Test.class.getName());

  public void doStuff()
  {
    log.fine("doing stuff");
  }
}


<resin xmlns="http://caucho.com/ns/resin">
  <log name="com.foo" level="fine" path="log/debug.log"
       timestamp="[%H:%M:%S] "/>
  ...
</resin>

Conventions on logging levels:

level use
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 developers. level="info" is infrequent, giving significant information like the server starting.

Some Resin Logging Names have been documented.

stdout-log and stderr-log

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.

Personal tools