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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to