I use Logback for logging and I have a question. I use AsyncAppender with ConsoleAppender. When application starts it creates thread pool with "logback-" thread names. All logging work is completed by "AsyncAppender-Worker-" thread. For what purpose thread pool with "logback-" thread names was created and what work does it do?
These threads are used for all other work logback needs to do in the background - time-based rollovers, socket appenders, async SMTP appenders etc.
By running a search on "logback-" over the logback codebase, I found only a single place where it's used: ExecutorServiceUtil
.
This helper class is used for creating executor services (accessed only by Contextbase.getScheduledExecutorService()
), and by tracking its usages I found these usages:
This is an exhaustive list. Note that all these are read from the source code. The time-based rollover, while it makes absolute sense to be asynchronous, is not documented to be, and could therefore change. The socket appender and the SMTP appender are documented to use a background thread.