Config: Important Loggers

From Resin 4.0 Wiki

Revision as of 00:00, 25 July 2012 by Cowan (Talk | contribs)
Jump to: navigation, search

Gears-48.png

We often get asked how to enable additional logging to debug a particular Resin behavior

On this page I will provide example of alternative log formats, and list a few key internal classes that can produce helpful debugging logs.

Log Formats

Resin's default log format (as of 4.0.29) is the following:

<log-handler name="" level="all" path="stdout:"
   timestamp="[%y-%m-%d %H:%M:%S.%s]"
   format=" {${thread}} ${log.message}"/>

Which produces log lines that look something like this:

[12-07-25 13:29:07.941] {main} Resin Professional 4.0.s120723 (built Mon, 23 Jul 2012 03:01:50 EDT)
[12-07-25 13:29:07.941] {main} 
[12-07-25 13:29:07.941] {main} Mac OS X 10.6.8 x86_64
[12-07-25 13:29:07.941] {main} Java(TM) SE Runtime Environment 1.6.0_33-b03-424-10M3720, MacRoman, en

This format isn't really ideal since it does not include the logger class name. The logger class name not only tells you where the log line came from, but also is useful if you want to adjust particular log levels to filter unwanted lines.

In recent version, the packaged resin.xml include a more useful TTCC (Time Thread Category Component) style log-handler that's commented out. I recommend you delete the default log-handler and uncomment this one:

<log-handler name="" level="all" path="stdout:"
    timestamp="%y-%m-%d %H:%M:%S.%s"
    format=" [${thread}] ${log.level} ${log.shortName} - ${log.message}"/>

Which produces log lines that look something like this:

12-07-25 13:36:02.587 [main] INFO ResinSystem - Resin Professional 4.0.s120723 (built Mon, 23 Jul 2012 03:01:50 EDT)
12-07-25 13:36:02.587 [main] INFO ResinSystem - 
12-07-25 13:36:02.587 [main] INFO ResinSystem - Mac OS X 10.6.8 x86_64
12-07-25 13:36:02.588 [main] INFO ResinSystem - Java(TM) SE Runtime Environment 1.6.0_33-b03-424-10M3720, MacRoman, en

So now we can see that these particular lines are produced by ResinSystem, one of the most important internal Resin classes. Unfortunately that's not enough information for filtering, since we need the full classname with package to set a logger level.

${log.shortName} is the class name with no package. Changing this to ${log.name} will produce the full class name. The full list of token is available in the Resin logging documentation here: http://www.caucho.com/resin-4.0/admin/logging.xtp .

12-07-25 14:14:38.377 [main] INFO com.caucho.env.service.ResinSystem - Resin Professional 4.0.s120723 (built Mon, 23 Jul 2012 03:01:50 EDT)
12-07-25 14:14:38.377 [main] INFO com.caucho.env.service.ResinSystem - 
12-07-25 14:14:38.378 [main] INFO com.caucho.env.service.ResinSystem - Mac OS X 10.6.8 x86_64
12-07-25 14:14:38.378 [main] INFO com.caucho.env.service.ResinSystem - Java(TM) SE Runtime Environment 1.6.0_33-b03-424-10M3720, MacRoman, en

Loggers

The packaged resin.xml include 3 loggers:

<logger name="" level="${log_level?:'info'}"/>
<logger name="com.caucho.java" level="config"/>
<logger name="com.caucho.loader" level="config"/>

The log_level variable comes from resin.properties and defaults everything to info level, with com.caucho.java and com.caucho.loader at a slightly more lower level.

It's important to notice there's also a level on log-handler! The log-handler level is the minimum level that will be accepted, regardless of what level is set for a logger. That means that even if you sent FINE level on a logger, if the log-handler level is set to INFO, it will only get log INFO level and higher.

Personal tools
TOOLBOX
LANGUAGES