Provide a QueuedConsoleAppender for Log4j 2 designed to queue log messages.
- Java and Maven installed
Add the dependency in your pom.xml
file:
<dependency>
<groupId>com.djdch.log4j</groupId>
<artifactId>log4j-queuedconsoleappender</artifactId>
<version>1.0.0</version>
</dependency>
Use the following to get the queue instance:
BlockingQueue<String> queue = QueuedConsoleAppender.getOutputQueue();
Use the following to disable the queue:
QueuedConsoleAppender.setRunning(false);