logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Ebersole" <steveebers...@austin.rr.com>
Subject Re: MDC in J2EE environment
Date Mon, 21 Apr 2003 14:14:27 GMT

>That's quite an original idea. What would happen if the same user were
>logged in twice?

I use weblogic, so for my purposes my closure would basically perform a
weblogic.security.Security.getCurrentlyExecutingUser().getName() call.  If
they were logged in twice, this would have the same effect as me placing the
user's username in context twice (i.e., once per thread).

I am thinking this registration would ideally occur just one time, in my
startup class/servlet.

This really only works for things, like executing user, which are always
needed and can be gotten in a generic fashion from the execution environment
already.


>Like you suggested in the previous paragraph. After modifying the MDC class
>to more or less match XMDC ckass, you would register a "closure" with the
>modified MDC class. The closure would be used instead of ContextCounter.

I guess the difference is that with this approach the MDC.put() would still
need to be performed for each inconing execution request.  That's why I was
asking about the InheritableThreadLocal ascept of MDC.  Would be great to
perform this "registration" at the level of the thread which would be used
to spawn all the execution threads.  Then the closure would automatically be
inherited into the context of each of these execution threads.

As I mentioned, I am lazy.  I really don't want to have to MDC.put() or
XMDC.put in each of my session bean methods if there is an easier way.


As an example, I am thinkning of something along these lines:

Closure class:
public class WeblogicUserLookup
{
    public String toString()
    {
        return
weblogic.security.Security.getCurrentlyExecutingUser().getName();
    }
}

then:
{
    ...
    MDC.put( "VEDA_USER_NAME", new WeblogicUserLookup() );
}

Hope this helps clarify.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message