logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sander Mägi <sander.m...@aqris.com>
Subject Logger, that would write log for a start only when 'commit' is called at the end.
Date Mon, 12 Nov 2007 14:51:25 GMT
Figured it out - I need to forward to a logger and not to an appender so 
configuration would be something like this:


log4j.appender.TARGET.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

log4j.rootLogger=DEBUG, P1


Heri Bender mentioned earlier, that this was once discussed - browsed 
through the mailing lists, but did not find it.

Anyway - if I write this and would contribute it to log4j would the 
project be interested in adding this appender? Otherwise I would just 
write it for myself and not bother you any more :)

best regards,
Sander Mägi

Sander Mägi wrote:
> Hi,
> I am trying to write a new appender for log4j mainly for production 
> web applications. It would create a separate log, that logs everything 
> in case the request ended with error and nothing if it completed 
> successfully. I thought to call it ProblemAppender.
> The idea I have is that at the beginnig of every request applications 
> would call a static method like
> ProblemAppender.beginRequest();
> and at the end it would call a method like
> ProblemAppender.endRequestSuccess() or .endRequestFailure();
> Problem appender would gather all logging events in a thread local 
> buffer and would either forward them to another appender when 
> endRequestFailure is called or discard them in case of 
> endRequestSuccess() is called.
> I would guess it would be configured something like that.
> ########
> log4j.appender.P1=com.aqris.plogger.ProblemAppender
> log4j.appender.P1.targetAppender=TARGET
> log4j.appender.TARGET=org.apache.log4j.ConsoleAppender
> log4j.appender.TARGET.layout=org.apache.log4j.PatternLayout
> log4j.appender.TARGET.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
> log4j.rootLogger=DEBUG, P1, TARGET
> ########
> Could anyone help me with these questions please?
>    1) Does this kind of solution perhaps exits already?
>    2) If not - what would be the way to get a reference to appender 
> 'TARGET' from the context of ProblemAppender.
>    3) Is this kind of solution a bad idea for some reason?
>    best regards,
> Sander Mägi
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org

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

View raw message