all,

I have encountered a lot of situations where I would like to inspect the 
servlet context information (such as session attributes, request attributes) 
with the application logging, without touching the original logging code. It's 
similar to the %t conversion specifier in the PatternLayout to print out the 
current thread name. 

I ended up developing my own solution using servlet filter and extension to the 
layout classes. (I tried to use MDC and it didn't work because the servlet 
request could be handled by different threads.) The result is very interesting. 
For instance, if you have this logging statement in your servlet application:

logger.debug("this is a test");

and you configure your pattern layout to be 

%p %S{userId} %m%n

then the log output will be:

DEBUG user_id_foo this is a test

assuming the logging statement was executed inside a servlet session with 
userId set to user_id_foo. 

I have created two new conversion specifiers %S and %R for attaching servlet 
session and request attributes. 

Would it make sense that I contribute it to Log4j in some way? I don't believe 
it belongs to the core. Maybe I can put it under contribs? Any help is 
appreciated. 

Thansk,
Winston

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to