log4j2: Flush logger buffer for an Async appender
<p>I have Async appender with <code>bufferSize="512"</code>. </p>

<p>In some situations I need to forcibly flush the buffer. How can I do that?</p>

<p>I don't what to close the LogManager, so <code>LogManager.shutdown();</code> is not an option.</p>

<p>Please help! </p>

<p><em>Update:</em> Here is the part of my log4j2.xml:</p>

<pre><code> &lt;Kafka name="Kafka" topic="logs-gexd-default"&gt;
    &lt;PatternLayout&gt;
       &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} %-5p %C{1}:%L - %m%n&lt;/pattern&gt;
    &lt;/PatternLayout&gt;
    &lt;Property name="bootstrap.servers"&gt;${kafkaAddress}&lt;/Property&gt;
 &lt;/Kafka&gt;
 &lt;Async name="AsyncKafka" bufferSize="512" blocking="false"&gt;
    &lt;AppenderRef ref="Kafka"/&gt;
 &lt;/Async&gt;
</code></pre>

<p>I have a Kafka appender inside of Async appender. Unfortunately neither Kafka appender not Async appender has immediateFlush field.</p>