|
|  |
Resin can perform access logging, specify where JDK 1.4
logging interface messages go, and redirect the stderr and
stdout for your applications.
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> .
| Attribute | Meaning | default |
| path | Filesystem path for the stream, see "Log Paths". Since Resin 3.0 | required
|
| rollover-period | how often to rollover the log. Specify
in days (15D), weeks (2W), months (1M), or hours (1h) | none
|
| rollover-size | max size of the log before a rollover in, bytes. | 1 meg
|
| timestamp | a 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> .
| Attribute | Meaning | default |
| path | Filesystem path for the stream, see "Log Paths". Since Resin 3.0 | required
|
| level | The log level. Since Resin 3.0 |
|
| rollover-period | how often to rollover the log. Specify
in days (15D), weeks (2W), months (1M), or hours (1h) | none
|
| rollover-size | max size of the log before a rollover, in bytes. | 1 meg
|
| timestamp | a 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>
...
|
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.
| Attribute | Meaning | default |
| path | Filesystem path for the stream, see "Log Paths". Since Resin 3.0 | required
|
| level | The log level. Since Resin 3.0 |
|
| format | Access log format. | see below
|
| rollover-period | how often to rollover the log. Specify
in days (15D), weeks (2W), months (1M), or hours (1h) | none
|
| rollover-size | max size of the log before a rollover, in bytes. | 10 meg
|
| bean-class | An class extending class com.caucho.server.log.AccessLog for custom logging. Since Resin 3.0
| com.caucho.server.log.AccessLog
|
| init | Bean-style initialization for the custom class. Resin 3.0 | n/a
|
| archive-format | Configures 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:
| %b | result content length
|
| %h | remote IP addr
|
| %{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 | request date with optional time format string.
|
| %T | time of request in seconds
|
| %u | remote user
|
| %U | request 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.
| Attribute | Meaning | default |
| name | A hierarchical name, typically aligned with the Java packaging names. Since Resin 3.0 | Enable all logs.
|
| path | Filesystem path for the stream, see "Log Paths". Since Resin 3.0 | required
|
| level | The log level. Since Resin 3.0 | info
|
| rollover-period | how often to rollover the log. Normally
in days (15D), weeks (2W) or months (1M), see
"Rollover Periods" for others. | none
|
| rollover-size | max size of the log before a rollover, in bytes. | 10 meg
|
| timestamp | a 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 value | Meaning
|
| "" | Debug everything
|
| com.caucho.jsp | Debug jsp
|
| com.caucho.java | Java compilation
|
| com.caucho.xsl | XSL debugging
|
| com.caucho.server.port | TCP port debugging and threading
|
| com.caucho.server.port.AcceptPool | port thread creation
|
| com.caucho.server.http | HTTP-related debugging
|
| com.caucho.server.webapp | web-app related debugging
|
| com.caucho.server.cache | Cache related debugging
|
| com.caucho.sql | Database pooling
|
| com.caucho.transaction | Transaction handling
|
| com.caucho.ejb | EJB 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);
}
}
...
}
|
The path for log tags may use path and regular expression
variables, and can also be directed to stdout and stderr.
| Variable | Value
|
| $server-root | The root of the server instance. Same as the -server-root argument.
|
| $host-root | The app-dir of the enclosing <host>
|
| $app-dir | The app-dir of the enclosing <web-app>
|
| $host0 ... $host9 | Regular expression replacement from a host url-regexp.
|
| $app0 ... $app9 | Regular expression replacement from a web-app url-regexp.
|
| $0 ... $9 | Regular expression replacement for the containing context (host or web-app)
|
| $foo | Java property value from System.getProperty("foo")
|
The level for log tags matches the levels in the JDK 1.4
class java.util.logging.Level .
| Name | API | Meaning
|
| off | | turn off logging
|
| severe | log.severe("...") | a serious failure, likely to prevent normal program execution
|
| warning | log.warning("...") | a potential problem
|
| info | log.info("...") | informational messages
|
| config | log.config("...") | static configuration messages, meant to assist in debugging problems associated with particular configurations
|
| fine | log.fine("...") | tracing information
|
| finer | log.finer("...") | fairly detailed tracing message
|
| finest | log.finest("...") | highly detailed tracing message
|
| all | | all messages should be logged
|
The timestamp for log tags is a format string which can contain percent
codes which are substituted with time and date values.
| Code | Meaning
|
| %a | day of week (short)
|
| %A | day of week (verbose)
|
| %b | day of month (short)
|
| %B | day of month (verbose)
|
| %c | Java locale date
|
| %d | day of month (two-digit)
|
| %H | 24-hour (two-digit)
|
| %I | 12-hour (two-digit)
|
| %j | day of year (three-digit)
|
| %m | month (two-digit)
|
| %M | minutes
|
| %p | am/pm
|
| %S | seconds
|
| %s | milliseconds
|
| %W | week in year (three-digit)
|
| %w | day of week (one-digit)
|
| %y | year (two-digit)
|
| %Y | year (four-digit)
|
| %Z | time zone (name)
|
| %z | time 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
|
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. |  |
|