[Yanel-dev] access logging: use logback?

Guillaume Déflache guillaume.deflache at wyona.com
Tue Dec 15 17:47:33 CET 2009


[I know I already pointed at some log4j stuff before but...]

Before reinventing the wheel I think we should have a deep (technical) 
look at logback (the successor of log4j, see <http://logback.qos.ch/>).

It provides:
- easy way to tag logs with a per-thread context[1] that can contain 
arbitrary data (username, cookie ID, geolocation or IP address come to 
mind!): http://logback.qos.ch/manual/mdc.html 
http://logback.qos.ch/manual/appenders.html#SiftingAppender
- special support for access logging, which, if maybe not useful to us 
because it /seems/ to only be able to operate before the webapp level at 
the HTTP level, may give use some inspiration: 
http://logback.qos.ch/access.html 
http://logback.qos.ch/manual/layouts.html#AccessPatternLayout 
http://logback.qos.ch/manual/appenders.html#AccessSiftingAppender & end 
of http://logback.qos.ch/manual/filters.html
- runtime configuration (via JMX) almost for free (for the cost of 
copy-pasting and registering a trivial ServletContextListener): 
http://logback.qos.ch/manual/jmxConfig.html
- faster logging than log4j


I think it's also a good way to test logback if we want to replace log4j 
with it in the longer term because of some new interesting features (as 
log4j development is more or less stale).

it would also be a way to get gently into JMX stuff.


WDYT?

Cheers,
    Guillaume

[1] granted, log4j have NDCs (cf. 
http://logging.apache.org/log4j/1.2/faq.html#3.1 and in 
http://logging.apache.org/log4j/1.2/manual.html look for "Nested 
Diagnostic Contexts") but they seem trickier to use as AFAICS we would 
have to manage threads and concurrency ourselves...


More information about the Yanel-development mailing list