title: Log4j2: Empty log file in case of parallel tests
body: <p>I have in my test automation project problem with logging. I'm using log4j2 logger with FileAppender. The way I'm using it is:</p>
  
  <pre><code>Logger logger = (Logger) LogManager.getLogger(loggerName);
  Appender appender = FileAppender.newBuilder()
              .withAppend(false)
              .withBufferedIo(true)
              .withFileName(DIR_NAME + File.separator + loggerName + ".log")
              .withIgnoreExceptions(false)
              .withImmediateFlush(true)
              .withLocking(false)
              .withLayout(PatternLayout.newBuilder().withPattern("%d{HH:mm:ss.SSS}  [%-5level] %msg%n").withCharset(Charset.forName("UTF-8")).build())
              .withName(loggerName)
              .build();
  
      appender.start();
      logger.addAppender(appender);
  </code></pre>
  
  <p>It works when I'm running single test. All data are visible in console, the file is created and test log is written in the file. Problem occurs in case of tests are running in parallel - in different threads. </p>
  
  <p>In this case, two different loggers and file appenders are created. Log files from both file appenders are created too and logs from both tests are visible in console. Everything seems to be fine, but every time one of these log files is empty. The empty log belongs to test which started later. </p>
  
  <p>I suspect problem with caching. The first file appender holds all cache for writing so the second one is not able to write. Am I right? What is the solution for this? </p>
  
  <p>Thank you.</p>