[logback-user] Failing appender cause nested logging calls in application
emerson.farrugia at gmail.com
Mon Apr 22 23:29:31 CEST 2013
I'm writing a logback appender that pushes errors to a remote API. It uses
supporting classes like RestTemplate and HttpClient to talk to the API.
I initially tried to register the appender through a logback XML
configuration, but I was warned that loggers named after the supporting
classes would be suppressed because they were created during the logback
configuration phase. Since those loggers are needed in other parts of the
system, and multi-step initialisation didn't seem feasible, I had to revise
The revised implementation programmatically registers the appender after
the logback configuration phase, and it seems to work correctly. The issue
is that I'm getting nested logging calls. For example, RestTemplate logs to
SLF4J. If there is a failure in RestTemplate, it sends a logging event to
SLF4J and therefore to logback, which goes to my appender, which will once
again try to hit the RestTemplate. Some mechanism seems to be protecting
against an infinite loop, since only four messages are logged, but I'm
wondering if there's something I can do to prevent my appender from
attempting to even try the nested call. MDC magic perhaps, assuming the
same thread is making the nested call?
Any feedback would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Logback-user