Hi Winston,

I was looking also for a simple solution for the same situation.

I thought, I could use MDC for this problem.
You are absolutelly right it is specific to Aplication Server provider,
wether the servlet request is handled by the same thread.

The only thing you can use for sure is the session object.

Another problem is to filter the logging statement
with the key value paars, that contained in servlet session (or request).

In your sample:
only the logging events with userId=user_id_foo 
is looged and not for userId=user_id_bar 

For only session specific attributes, no servlet filter
is nessesary, because the logging specific attributes can be 
writen during authorisation phase.

My opinion, this stuff belongs to the core, because neither NDC, nor MDC
could be used for this purpose.

Could you please post your solution.

Ciao
Arthur Brown


> 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]
> 

-- 
DSL Komplett von GMX +++ Superg�nstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl

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

Reply via email to