You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ashton Vaz <as...@rocketmail.com> on 2001/02/28 07:34:04 UTC

Re: Using NDC to enable logging over a thread of control

Apologies for the cross post, but I think this should be read by members
of the dev list as well.

Scott,

    I think I know what you're aiming for.  Essentially you want the
logging trail grouped by "user".  This transient/dynamic association I
guess, can be generalized to mean association of code executed in a
particular "context" or "session".  This requirement has come up a few
times at work.  As far as I know, this problem hasn't been solved.  The
current architecture is fine for simpler applications where the log
messages all arise within the same context, but in J2EE apps, where
multiple objects across VMs are servicing lots of "users" the need arises
to seperate/filter logged messages based on the "context".  At work, we
hope to have some solution for this as it is critical that the log
messages be filtered (or turned on and off) based on this "session"
context, but the progress has been slow.  Maybe others on this list are
having the same problem?  Currently, I can see 2 options:
a) Having categories associated with "Session"/"UID" classes just like
appenders are attached to categories or
b) Have the ability to turn on/turn off the sessions implemented as
methods with the current Category object.

Comments? Suggestions?

Ashton


From: "Scott M Stark" <Sc...@displayscape.com> 
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org> 
Subject: Re: Using NDC to enable logging over a thread of control 
Date: Fri, 16 Feb 2001 19:55:44 -0800 


I think you have part of the picture correct, but what I'm missing here is

how all of the
log msgs in code that the thread interacts with ends up getting associated

with this
'UserDebug' category.

For example, I'm using a Category per Java package paradigm in which every
class in a package logs through a Category with a name equal to the 
package name.
So, if the servlet interacts with two packages in addition to the servlet 
code,
say com.dscape.security and com.dscape.mail, I want any msgs issued 
through
the Category("com.dscape.security") and Category("com.dscape.mail") to 
show
up in the Category("'UserDebug") appender regardless of their priority for

this
particular call stack only. If my understanding of Category is correct, 
I'm looking
for a transient heirachy of Categorys based on the thread stack rather 
than any
static category namespace.

----- Original Message -----
From: Christopher Taylor
To: LOG4J Users Mailing List
Sent: Friday, February 16, 2001 6:56 PM
Subject: Re: Using NDC to enable logging over a thread of control


If I'm understanding your need correctly, you could probably do this in 
the following way without any code changes to Log4J:

- if the user is authenticated, you can get the principal from the 
HttpServletRequest.
- If that user has been "enabled for debugging", get an instance of a 
category for that user that is one step below a well-known
debugging category (for example, category "UserDebug" logs to a special 
appender called "DebugUserProblems"). So, if I was
authenticated with an SSL certificate any my distinguished name was 
"uid=ctaylor,dc=java-internals,dc=com", you could make the
category name "UserDebug.ctaylor". One technique for doing this is to 
always get an instance of a category for logging in your
application, but it depends if the user is on the debug list or not if 
calls go to the special log. You can put that instance of the
Category into the request attributes.

Let me know if I'm misinterpreting you.

-Chris

On Friday, February 16, 2001, at 06:50 PM, Scott M Stark wrote:


I'm looking to correlate msgs with the active thread and to have the 
Priority of
the thread override any Category.xxx() log msg invocation so that all log 
statements
in this thread of control are rendered.

The use case for this is a production J2EE server housing many EJBs, 
servlets, etc.
and there is a problem report for particular user interacting with one 
servlet. I don't
want to have to crank up the priority limit to dump out all possible msgs.

I just want
to toggle a request parameter that triggers logging throughout one 
particular thread of
control the user is interacting with.

----- Original Message -----
From: "Christopher Taylor" <cs...@pacbell.net>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Friday, February 16, 2001 6:27 PM
Subject: Re: Using NDC to enable logging over a thread of control



Could you go into a little more detail? Do you want to correlate messages 
with Threads
or with clients?

-Chris

Scott M Stark wrote:


One common logging task I use frequently in server development is the 
ability to
enable logging across a thread of control beginning at some entry point. 
An example
is enabling all log msgs regardless of priority that are executed within a

particular
servlet's service() method. Going through the log4j api I can't see a way 
to do this.
Is this possible?

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Re: Using NDC to enable logging over a thread of control

Posted by Ashton Vaz <as...@rocketmail.com>.
How do you accomplish the task of associating log messages to session?

some sort of method like: log.info (sessionId, messageString) ?

ashton


--- Scott M Stark <Sc...@displayscape.com> wrote:
> This is a correct assessment of the need. I have such a feature in a
> custom logging
> framework that I have created that is very similar to log4j. In that
> logging framework
> the equivalent of the NDC allows you to push an override priority in
> addition to
> a context name and any logmsg issued within the context behaves as
> though its
> priority meets the threshold requirement regardless of what priority was
> used.
> I have not had a chance to see if something similar could be added to
> log4j or
> whether a custom Category would apply.
> 
> ----- Original Message ----- 
> From: "Ashton Vaz" <as...@rocketmail.com>
> To: <lo...@jakarta.apache.org>; <lo...@jakarta.apache.org>
> Sent: Tuesday, February 27, 2001 10:34 PM
> Subject: Re: Using NDC to enable logging over a thread of control 
> 
> 
> > Apologies for the cross post, but I think this should be read by
> members
> > of the dev list as well.
> > 
> > Scott,
> > 
> >     I think I know what you're aiming for.  Essentially you want the
> > logging trail grouped by "user".  This transient/dynamic association I
> > guess, can be generalized to mean association of code executed in a
> > particular "context" or "session".  This requirement has come up a few
> > times at work.  As far as I know, this problem hasn't been solved. 
> The
> > current architecture is fine for simpler applications where the log
> > messages all arise within the same context, but in J2EE apps, where
> > multiple objects across VMs are servicing lots of "users" the need
> arises
> > to seperate/filter logged messages based on the "context".  At work,
> we
> > hope to have some solution for this as it is critical that the log
> > messages be filtered (or turned on and off) based on this "session"
> > context, but the progress has been slow.  Maybe others on this list
> are
> > having the same problem?  Currently, I can see 2 options:
> > a) Having categories associated with "Session"/"UID" classes just like
> > appenders are attached to categories or
> > b) Have the ability to turn on/turn off the sessions implemented as
> > methods with the current Category object.
> > 
> > Comments? Suggestions?
> > 
> > Ashton
> > 
> > 

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

Re: Using NDC to enable logging over a thread of control

Posted by Scott M Stark <Sc...@displayscape.com>.
This is a correct assessment of the need. I have such a feature in a custom logging
framework that I have created that is very similar to log4j. In that logging framework
the equivalent of the NDC allows you to push an override priority in addition to
a context name and any logmsg issued within the context behaves as though its
priority meets the threshold requirement regardless of what priority was used.
I have not had a chance to see if something similar could be added to log4j or
whether a custom Category would apply.

----- Original Message ----- 
From: "Ashton Vaz" <as...@rocketmail.com>
To: <lo...@jakarta.apache.org>; <lo...@jakarta.apache.org>
Sent: Tuesday, February 27, 2001 10:34 PM
Subject: Re: Using NDC to enable logging over a thread of control 


> Apologies for the cross post, but I think this should be read by members
> of the dev list as well.
> 
> Scott,
> 
>     I think I know what you're aiming for.  Essentially you want the
> logging trail grouped by "user".  This transient/dynamic association I
> guess, can be generalized to mean association of code executed in a
> particular "context" or "session".  This requirement has come up a few
> times at work.  As far as I know, this problem hasn't been solved.  The
> current architecture is fine for simpler applications where the log
> messages all arise within the same context, but in J2EE apps, where
> multiple objects across VMs are servicing lots of "users" the need arises
> to seperate/filter logged messages based on the "context".  At work, we
> hope to have some solution for this as it is critical that the log
> messages be filtered (or turned on and off) based on this "session"
> context, but the progress has been slow.  Maybe others on this list are
> having the same problem?  Currently, I can see 2 options:
> a) Having categories associated with "Session"/"UID" classes just like
> appenders are attached to categories or
> b) Have the ability to turn on/turn off the sessions implemented as
> methods with the current Category object.
> 
> Comments? Suggestions?
> 
> Ashton
> 
> 



Re: Using NDC to enable logging over a thread of control

Posted by Scott M Stark <Sc...@displayscape.com>.
This is a correct assessment of the need. I have such a feature in a custom logging
framework that I have created that is very similar to log4j. In that logging framework
the equivalent of the NDC allows you to push an override priority in addition to
a context name and any logmsg issued within the context behaves as though its
priority meets the threshold requirement regardless of what priority was used.
I have not had a chance to see if something similar could be added to log4j or
whether a custom Category would apply.

----- Original Message ----- 
From: "Ashton Vaz" <as...@rocketmail.com>
To: <lo...@jakarta.apache.org>; <lo...@jakarta.apache.org>
Sent: Tuesday, February 27, 2001 10:34 PM
Subject: Re: Using NDC to enable logging over a thread of control 


> Apologies for the cross post, but I think this should be read by members
> of the dev list as well.
> 
> Scott,
> 
>     I think I know what you're aiming for.  Essentially you want the
> logging trail grouped by "user".  This transient/dynamic association I
> guess, can be generalized to mean association of code executed in a
> particular "context" or "session".  This requirement has come up a few
> times at work.  As far as I know, this problem hasn't been solved.  The
> current architecture is fine for simpler applications where the log
> messages all arise within the same context, but in J2EE apps, where
> multiple objects across VMs are servicing lots of "users" the need arises
> to seperate/filter logged messages based on the "context".  At work, we
> hope to have some solution for this as it is critical that the log
> messages be filtered (or turned on and off) based on this "session"
> context, but the progress has been slow.  Maybe others on this list are
> having the same problem?  Currently, I can see 2 options:
> a) Having categories associated with "Session"/"UID" classes just like
> appenders are attached to categories or
> b) Have the ability to turn on/turn off the sessions implemented as
> methods with the current Category object.
> 
> Comments? Suggestions?
> 
> Ashton
> 
> 



Re: Using NDC to enable logging over a thread of control

Posted by Ceki Gülcü <cg...@qos.ch>.
Aston,

Have you considered using a different category hierarchy per Session/UID? Ceki

At 22:34 27.02.2001 -0800, Ashton Vaz wrote:
>Apologies for the cross post, but I think this should be read by members
>of the dev list as well.
>
>Scott,
>
>    I think I know what you're aiming for.  Essentially you want the
>logging trail grouped by "user".  This transient/dynamic association I
>guess, can be generalized to mean association of code executed in a
>particular "context" or "session".  This requirement has come up a few
>times at work.  As far as I know, this problem hasn't been solved.  The
>current architecture is fine for simpler applications where the log
>messages all arise within the same context, but in J2EE apps, where
>multiple objects across VMs are servicing lots of "users" the need arises
>to seperate/filter logged messages based on the "context".  At work, we
>hope to have some solution for this as it is critical that the log
>messages be filtered (or turned on and off) based on this "session"
>context, but the progress has been slow.  Maybe others on this list are
>having the same problem?  Currently, I can see 2 options:
>a) Having categories associated with "Session"/"UID" classes just like
>appenders are attached to categories or
>b) Have the ability to turn on/turn off the sessions implemented as
>methods with the current Category object.
>
>Comments? Suggestions?
>
>Ashton
>
>
>From: "Scott M Stark" <Sc...@displayscape.com> 
>To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org> 
>Subject: Re: Using NDC to enable logging over a thread of control 
>Date: Fri, 16 Feb 2001 19:55:44 -0800 
>
>
>I think you have part of the picture correct, but what I'm missing here is
>
>how all of the
>log msgs in code that the thread interacts with ends up getting associated
>
>with this
>'UserDebug' category.
>
>For example, I'm using a Category per Java package paradigm in which every
>class in a package logs through a Category with a name equal to the 
>package name.
>So, if the servlet interacts with two packages in addition to the servlet 
>code,
>say com.dscape.security and com.dscape.mail, I want any msgs issued 
>through
>the Category("com.dscape.security") and Category("com.dscape.mail") to 
>show
>up in the Category("'UserDebug") appender regardless of their priority for
>
>this
>particular call stack only. If my understanding of Category is correct, 
>I'm looking
>for a transient heirachy of Categorys based on the thread stack rather 
>than any
>static category namespace.
>
>----- Original Message -----
>From: Christopher Taylor
>To: LOG4J Users Mailing List
>Sent: Friday, February 16, 2001 6:56 PM
>Subject: Re: Using NDC to enable logging over a thread of control
>
>
>If I'm understanding your need correctly, you could probably do this in 
>the following way without any code changes to Log4J:
>
>- if the user is authenticated, you can get the principal from the 
>HttpServletRequest.
>- If that user has been "enabled for debugging", get an instance of a 
>category for that user that is one step below a well-known
>debugging category (for example, category "UserDebug" logs to a special 
>appender called "DebugUserProblems"). So, if I was
>authenticated with an SSL certificate any my distinguished name was 
>"uid=ctaylor,dc=java-internals,dc=com", you could make the
>category name "UserDebug.ctaylor". One technique for doing this is to 
>always get an instance of a category for logging in your
>application, but it depends if the user is on the debug list or not if 
>calls go to the special log. You can put that instance of the
>Category into the request attributes.
>
>Let me know if I'm misinterpreting you.
>
>-Chris
>
>On Friday, February 16, 2001, at 06:50 PM, Scott M Stark wrote:
>
>
>I'm looking to correlate msgs with the active thread and to have the 
>Priority of
>the thread override any Category.xxx() log msg invocation so that all log 
>statements
>in this thread of control are rendered.
>
>The use case for this is a production J2EE server housing many EJBs, 
>servlets, etc.
>and there is a problem report for particular user interacting with one 
>servlet. I don't
>want to have to crank up the priority limit to dump out all possible msgs.
>
>I just want
>to toggle a request parameter that triggers logging throughout one 
>particular thread of
>control the user is interacting with.
>
>----- Original Message -----
>From: "Christopher Taylor" <cs...@pacbell.net>
>To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
>Sent: Friday, February 16, 2001 6:27 PM
>Subject: Re: Using NDC to enable logging over a thread of control
>
>
>
>Could you go into a little more detail? Do you want to correlate messages 
>with Threads
>or with clients?
>
>-Chris
>
>Scott M Stark wrote:
>
>
>One common logging task I use frequently in server development is the 
>ability to
>enable logging across a thread of control beginning at some entry point. 
>An example
>is enabling all log msgs regardless of priority that are executed within a
>
>particular
>servlet's service() method. Going through the log4j api I can't see a way 
>to do this.
>Is this possible?
>
>__________________________________________________
>Do You Yahoo!?
>Get email at your own domain with Yahoo! Mail. 
>http://personal.mail.yahoo.com/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

----
Ceki Gülcü          Web:   http://qos.ch      
av. de Rumine 5     email: cgu@qos.ch (preferred)
CH-1005 Lausanne           ceki_gulcu@yahoo.com
Switzerland         Tel: ++41 21 351 23 15


Re: Using NDC to enable logging over a thread of control

Posted by Ceki Gülcü <cg...@qos.ch>.
Aston,

Have you considered using a different category hierarchy per Session/UID? Ceki

At 22:34 27.02.2001 -0800, Ashton Vaz wrote:
>Apologies for the cross post, but I think this should be read by members
>of the dev list as well.
>
>Scott,
>
>    I think I know what you're aiming for.  Essentially you want the
>logging trail grouped by "user".  This transient/dynamic association I
>guess, can be generalized to mean association of code executed in a
>particular "context" or "session".  This requirement has come up a few
>times at work.  As far as I know, this problem hasn't been solved.  The
>current architecture is fine for simpler applications where the log
>messages all arise within the same context, but in J2EE apps, where
>multiple objects across VMs are servicing lots of "users" the need arises
>to seperate/filter logged messages based on the "context".  At work, we
>hope to have some solution for this as it is critical that the log
>messages be filtered (or turned on and off) based on this "session"
>context, but the progress has been slow.  Maybe others on this list are
>having the same problem?  Currently, I can see 2 options:
>a) Having categories associated with "Session"/"UID" classes just like
>appenders are attached to categories or
>b) Have the ability to turn on/turn off the sessions implemented as
>methods with the current Category object.
>
>Comments? Suggestions?
>
>Ashton
>
>
>From: "Scott M Stark" <Sc...@displayscape.com> 
>To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org> 
>Subject: Re: Using NDC to enable logging over a thread of control 
>Date: Fri, 16 Feb 2001 19:55:44 -0800 
>
>
>I think you have part of the picture correct, but what I'm missing here is
>
>how all of the
>log msgs in code that the thread interacts with ends up getting associated
>
>with this
>'UserDebug' category.
>
>For example, I'm using a Category per Java package paradigm in which every
>class in a package logs through a Category with a name equal to the 
>package name.
>So, if the servlet interacts with two packages in addition to the servlet 
>code,
>say com.dscape.security and com.dscape.mail, I want any msgs issued 
>through
>the Category("com.dscape.security") and Category("com.dscape.mail") to 
>show
>up in the Category("'UserDebug") appender regardless of their priority for
>
>this
>particular call stack only. If my understanding of Category is correct, 
>I'm looking
>for a transient heirachy of Categorys based on the thread stack rather 
>than any
>static category namespace.
>
>----- Original Message -----
>From: Christopher Taylor
>To: LOG4J Users Mailing List
>Sent: Friday, February 16, 2001 6:56 PM
>Subject: Re: Using NDC to enable logging over a thread of control
>
>
>If I'm understanding your need correctly, you could probably do this in 
>the following way without any code changes to Log4J:
>
>- if the user is authenticated, you can get the principal from the 
>HttpServletRequest.
>- If that user has been "enabled for debugging", get an instance of a 
>category for that user that is one step below a well-known
>debugging category (for example, category "UserDebug" logs to a special 
>appender called "DebugUserProblems"). So, if I was
>authenticated with an SSL certificate any my distinguished name was 
>"uid=ctaylor,dc=java-internals,dc=com", you could make the
>category name "UserDebug.ctaylor". One technique for doing this is to 
>always get an instance of a category for logging in your
>application, but it depends if the user is on the debug list or not if 
>calls go to the special log. You can put that instance of the
>Category into the request attributes.
>
>Let me know if I'm misinterpreting you.
>
>-Chris
>
>On Friday, February 16, 2001, at 06:50 PM, Scott M Stark wrote:
>
>
>I'm looking to correlate msgs with the active thread and to have the 
>Priority of
>the thread override any Category.xxx() log msg invocation so that all log 
>statements
>in this thread of control are rendered.
>
>The use case for this is a production J2EE server housing many EJBs, 
>servlets, etc.
>and there is a problem report for particular user interacting with one 
>servlet. I don't
>want to have to crank up the priority limit to dump out all possible msgs.
>
>I just want
>to toggle a request parameter that triggers logging throughout one 
>particular thread of
>control the user is interacting with.
>
>----- Original Message -----
>From: "Christopher Taylor" <cs...@pacbell.net>
>To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
>Sent: Friday, February 16, 2001 6:27 PM
>Subject: Re: Using NDC to enable logging over a thread of control
>
>
>
>Could you go into a little more detail? Do you want to correlate messages 
>with Threads
>or with clients?
>
>-Chris
>
>Scott M Stark wrote:
>
>
>One common logging task I use frequently in server development is the 
>ability to
>enable logging across a thread of control beginning at some entry point. 
>An example
>is enabling all log msgs regardless of priority that are executed within a
>
>particular
>servlet's service() method. Going through the log4j api I can't see a way 
>to do this.
>Is this possible?
>
>__________________________________________________
>Do You Yahoo!?
>Get email at your own domain with Yahoo! Mail. 
>http://personal.mail.yahoo.com/
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

----
Ceki Gülcü          Web:   http://qos.ch      
av. de Rumine 5     email: cgu@qos.ch (preferred)
CH-1005 Lausanne           ceki_gulcu@yahoo.com
Switzerland         Tel: ++41 21 351 23 15