Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
sysout-over-slf4j causes deadlock on log rolling #3
We recently introduced sysout-over-slf4j into an application that has been running steadily for a couple of years. No other code changes were made other than adding the sysout-over-slf4j dependency and the one line of code to initialize it. We immediately started seeing nightly deadlocks when Logback went to roll log files. It occurred most nights. Upon removing sysout-over-slf4j, the deadlocks stopped.
We've used sysout-over-slf4j in past projects without this issue. A primary difference is that this application does a lot of very rapid logging across numerous threads. Below is a thread dump.
Found one Java-level deadlock:
Found 1 deadlock.
First thanks for writing this. However, I am having the same problem. Took me forever to figure it out because it is somewhat intermittent and apparently I'm not heavy enough to do a thread dump. When the roll fails, the tmp file is created, the original file is deleted and logback says that it is about to zip the file, then hangs. If it fails on root logger, the deadlock is hard and the server has to be rebooted. I am running this in Tomcat 7 as windows service, Java 7 SDK, Windows 7, sysout-overslf4j-1.0.2.jar, slf4j 1.7.7.jar, logback 1.1.2. If I turn off zip compression, it seems to be working fine. If I remove the lidalia listener from server/conf/web.xml, i can use zip compression. All testing is using a size based policy of 3kb and loading a page that populates that logger. I say "seems" because I might just be getting a string of good luck.
From the logback documentation setting debug=true when configuring logback will send output to system.out (specifically when rolling) using the OnConsoleStatusListener. This causes the deadlock in my case.
Setting debug=false should use the NopStatusListener