Failing appender cause nested logging calls in application

Hi, 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 implementation. 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. Thanks, Emerson

Some of the appenders in logback use a threadlocal to detect recusive calls, maybe you can use the same approach. David -- View this message in context: http://logback.10977.n7.nabble.com/Failing-appender-cause-nested-logging-cal... Sent from the Users mailing list archive at Nabble.com.
participants (2)
-
diroussel
-
Emerson Farrugia