'How to force logback to flush logs from a single logger tied to AsyncAppender

In SpringBoot, I am using Logback's AsyncAppender to output logs asynchronously. I would like to know how to force a flush from a single logger that tied to AsyncAppender. I know that I can flush all the loggers with the following code.

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.stop();

For a single logger, is there any way to flush the log queued by AsyncAppender like LoggerFactory.getLogger().flush?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source