Log
Resin

Change Log
Documentation

Orientation
Features
Installation
Configuration
Web Applications
JSP
Servlets and Filters
Databases
Admin (JMX)
Security
XML and XSLT
XTP
Resources (JNDI)
Performance
Protocols
Third-party
Troubleshooting

env
web-app
resin.conf
log
el vars
init
index
Common Tasks
Relax Schema
Config FAQ
Scrapbook
resin.conf
Configuration
el vars

Resin can perform access logging, specify where JDK 1.4 logging interface messages go, and redirect the stderr and stdout for your applications.

  1. Log Configuration Tags
    1. stdout-log
    2. stderr-log
    3. access-log
    4. log
  2. Log Paths
  3. Log Levels
  4. Timestamp Format String

Log Configuration Tags

stdout-log

child of: resin, server, host-default, web-app-default, web-app
default: By default, uses the JDK's destination for System.out.

Configure the destination for System.out.

Usage of the stdout-log overrides a previous usage. For example, specifying stdout-log as a child of a <web-app> causes a redirection of System.out for that web application only, and will override the System.out location in the enclosing <host> .

AttributeMeaningdefault
pathFilesystem path for the stream, see "Log Paths". Since Resin 3.0required
rollover-periodhow often to rollover the log. Specify in days (15D), weeks (2W), months (1M), or hours (1h)none
rollover-sizemax size of the log before a rollover in, bytes.1 meg
timestampa timestamp format string to use at the beginning of each log line. Since Resin 3.0

The following example configures System.out for a <host> . All web-apps in the host will write to the same output file.

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

stderr-log

child of: resin, server, host-default, web-app-default, web-app
default:

Configure the destination for System.err.

Usage of the stderr-log overrides a previous usage. For example, specifying stderr-log as a child of a <web-app> causes a redirection of System.err for that web application only, and will override the System.err location in the enclosing <host> .

AttributeMeaningdefault
pathFilesystem path for the stream, see "Log Paths". Since Resin 3.0required
levelThe log level. Since Resin 3.0
rollover-periodhow often to rollover the log. Specify in days (15D), weeks (2W), months (1M), or hours (1h)none
rollover-sizemax size of the log before a rollover, in bytes.1 meg
timestampa timestamp format string to use at the beginning of each log line. Since Resin 3.0

The following example configures System.err for a <host> . All web-apps in the host will write to the same output file.

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

access-log

Resin 2.1

child of: server, host-default, host, web-app-default, web-app
default:

Specify the access log file.

As a child of <web-app> , overrides the definition in the <host> that the web-app is deployed in. As a child of <host> , overrides the definition in the <server> that the host is in.

AttributeMeaningdefault
pathFilesystem path for the stream, see "Log Paths". Since Resin 3.0required
levelThe log level. Since Resin 3.0
formatAccess log format.see below
rollover-periodhow often to rollover the log. Specify in days (15D), weeks (2W), months (1M), or hours (1h)none
rollover-sizemax size of the log before a rollover, in bytes.10 meg
bean-classAn class extending class com.caucho.server.log.AccessLog for custom logging. Since Resin 3.0 com.caucho.server.log.AccessLog
initBean-style initialization for the custom class. Resin 3.0n/a
archive-formatConfigures the name used to archive old log files. Since Resin 2.1

...
<host id=''>
  <access-log path='log/access.log'>
    <rollover-period>2W</rollover-period>
  </access-log>
  ...
</host>
...

The access log formatting variables follow the Apache variables:

%bresult content length
%hremote IP addr
%{xxx}irequest header xxx
%{xxx}oresponse header xxx
%{xxx}ccookie value xxx
%nrequest attribute
%rrequest URL
%sstatus code
%{xxx}trequest date with optional time format string.
%Ttime of request in seconds
%uremote user
%Urequest URI

The default format is:

 "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 

The bean-class allows for custom logging. Application can extend a custom class from com.caucho.http.log.AbstractAccessLog. The init-param parameters set bean parameters in the custom class.

...
<host id='foo.com'>
  <access-log href='$server-root/foo/error.log'
             rollover-period='1W'
             class-name='test.MyLog'>
    <init-param foo='bar'/>
  </access-log>
  ...
</host>
...

log

child of: resin, server, host-default, host, web-app-default, web-app
default:

Configure the amount and destination of debug logging for the JDK 1.4 java.util.logging.* API.

AttributeMeaningdefault
nameA hierarchical name, typically aligned with the Java packaging names. Since Resin 3.0Enable all logs.
pathFilesystem path for the stream, see "Log Paths". Since Resin 3.0required
levelThe log level. Since Resin 3.0info
rollover-periodhow often to rollover the log. Normally in days (15D), weeks (2W) or months (1M), see "Rollover Periods" for others.none
rollover-sizemax size of the log before a rollover, in bytes.10 meg
timestampa timestamp format string to use at the beginning of each log line. Since Resin 3.0

For example, to log everything to standard error use:

<resin>
  <log name='' level='all' path='stderr:' timestamp="[%H:%M:%S.%s]"/>
  ...
</resin>

Resin's logging is based on Resin's source class names. The following are useful logs.

log name valueMeaning
""Debug everything
com.caucho.jspDebug jsp
com.caucho.javaJava compilation
com.caucho.xslXSL debugging
com.caucho.server.portTCP port debugging and threading
com.caucho.server.port.AcceptPoolport thread creation
com.caucho.server.httpHTTP-related debugging
com.caucho.server.webappweb-app related debugging
com.caucho.server.cacheCache related debugging
com.caucho.sqlDatabase pooling
com.caucho.transactionTransaction handling
com.caucho.ejbEJB handling

Multiple log specifications are cumulative:

multiple log
<resin>
  <log name='' level='warn' path='stderr:' timestamp='[%H:%M:%S.%s]'/>

  <!-- keep full debugging information around for 1 day -->
  <log name='' level='info' 
       path='log/debug.log' 
       timestamp='[%H:%M:%S.%s]'
       rollover-period='1D' />

  ...
</resin>

You can take advantage of Resin's logging facility to add logging to your application. It's a good idea to keep such log messages in your code, when your application goes into production you can set the log level to warn; if problem's occur you can set it to finest and still have all of the information you need to troubleshoot.

com.caucho.log.Log is a simple utility class which opens a Logger based on a class name. Portable applications will want to write their own equivalent for Resin's Log class.

import java.util.logging.Logger;
import java.util.logging.Level;

import com.caucho.log.Log;

public class Foo {
  protected final static Logger log = Log.open(Foo.class);

  ...
  void doFoo(String bar)
  {
    // check for log level if your logging call does anything more
    // than pass parameters
    if (log.isLoggable(Level.FINER))
        log.entering("Foo","doFoo()", new Object[] { bar });
    ...

    log.info(...);

    try {
        ...
    } catch (ExpectedException ex) {
      log.log(Level.FINE, "expected exception", ex);
    }
  }
  ...
}

Log Paths

The path for log tags may use path and regular expression variables, and can also be directed to stdout and stderr.

PathResult
stdout:redirect to stdout, see <stdout-log>
stderr:redirect to stderr, see <stderr-log>

VariableValue
$server-rootThe root of the server instance. Same as the -server-root argument.
$host-rootThe app-dir of the enclosing <host>
$app-dirThe app-dir of the enclosing <web-app>
$host0 ... $host9Regular expression replacement from a host url-regexp.
$app0 ... $app9Regular expression replacement from a web-app url-regexp.
$0 ... $9Regular expression replacement for the containing context (host or web-app)
$fooJava property value from System.getProperty("foo")

Log Levels

The level for log tags matches the levels in the JDK 1.4 class java.util.logging.Level .

NameAPIMeaning
offturn off logging
severelog.severe("...")a serious failure, likely to prevent normal program execution
warninglog.warning("...")a potential problem
infolog.info("...")informational messages
configlog.config("...")static configuration messages, meant to assist in debugging problems associated with particular configurations
finelog.fine("...")tracing information
finerlog.finer("...")fairly detailed tracing message
finestlog.finest("...")highly detailed tracing message
allall messages should be logged

Timestamp Format String

The timestamp for log tags is a format string which can contain percent codes which are substituted with time and date values.

CodeMeaning
%aday of week (short)
%Aday of week (verbose)
%bday of month (short)
%Bday of month (verbose)
%cJava locale date
%dday of month (two-digit)
%H24-hour (two-digit)
%I12-hour (two-digit)
%jday of year (three-digit)
%mmonth (two-digit)
%Mminutes
%pam/pm
%Sseconds
%smilliseconds
%Wweek in year (three-digit)
%wday of week (one-digit)
%yyear (two-digit)
%Yyear (four-digit)
%Ztime zone (name)
%ztime zone (+/-0800)

typical timestamp for the log tag
  <caucho.com>
    <log name='' level='all' path='stderr:' timestamp="[%H:%M:%S.%s]"/>

    ...
  </caucho.com>

[22:50:11.648] Application[/doc] starting
[22:50:11.698] http listening to *:8080
[22:50:11.828] hmux listening to *:6802


resin.conf
Configuration
el vars
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.