logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serdyn du Toit <dutoi...@gmail.com>
Subject flushing async loggers
Date Sun, 21 Jun 2015 21:54:02 GMT

How do I flush async loggers?

I'm currently testing some code with multiple threads - when the test is
finished almost none of the log statements have been printed.  This also
makes me worried about my production code's logging when the server
gracefully shuts down (will it just not log as it the case in my test, or
will it actually flush...)

The only clue I've found on how to do this is the following stackoverflow


But the solution just doesn't seem to work for me.

I don't think its relevant to the question, but here is my log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="WARN">
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
%msg%n" />
<RollingRandomAccessFile name="FILE" fileName="logs/webapplog.log"

      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
%msg%n" />
        <TimeBasedTriggeringPolicy />


    <root level="WARN">
      <appender-ref ref="CONSOLE" />
      <appender-ref ref="FILE" />

And then I have a LogManager class encapsulating all my logging code that
enables async logging:

public class LogManager {

// Enable Log4j2 async logging
static {


Any help appreciated!!!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message