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 Ed...@Compart.net on 2001/01/10 10:24:57 UTC

New logger needs help: tracing with NCDs

Hi there,

I wonder if it is possible to do the following with log4j:

I would like to trace in a kind of transaction based environment.

Meaning: when a new transaction(*) starts, I would like to
create a trace stack. During the transaction, all trace messages
should be cached on this stack - but they should not be emitted.

When the transaction ends there should be two possibilities:
- transaction fails:
    emit all messages that have been cached in the stack
- transaction succeeds
    throw away the stack and all its messages

I think the underlying idea is quite useful: if there is no problem, I dont
need to see any message. If there is a problem, I will receive
all messages that belong to the context of the problem.

I had a look at org.log4j.NDC; but I fear that is not exactly what I am
looking for. I am wondering if I can achieve my goal by writting own
appenders ... so please tell me what you think: is it possible to
implement such functionality using log4j?

thx,

edwin günthner

(*) a transaction is just a set of actions that belong together; it might
  happen in its own thread


Re: New logger needs help: tracing with NCDs

Posted by Ceki Gulcu <cg...@urbanet.ch>.
Edwin,

I belive that the SMTPAppender does precisely what you described. Ceki

At 10:24 10.01.2001 +0100, you wrote:
>Hi there,
>
>I wonder if it is possible to do the following with log4j:
>
>I would like to trace in a kind of transaction based environment.
>
>Meaning: when a new transaction(*) starts, I would like to
>create a trace stack. During the transaction, all trace messages
>should be cached on this stack - but they should not be emitted.
>
>When the transaction ends there should be two possibilities:
>- transaction fails:
>     emit all messages that have been cached in the stack
>- transaction succeeds
>     throw away the stack and all its messages
>
>I think the underlying idea is quite useful: if there is no problem, I dont
>need to see any message. If there is a problem, I will receive
>all messages that belong to the context of the problem.
>
>I had a look at org.log4j.NDC; but I fear that is not exactly what I am
>looking for. I am wondering if I can achieve my goal by writting own
>appenders ... so please tell me what you think: is it possible to
>implement such functionality using log4j?
>
>thx,
>
>edwin günthner
>
>(*) a transaction is just a set of actions that belong together; it might
>   happen in its own thread
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org