I am trying to setup async logging and want to write to log ONLY if the buffer size limit has been reached.
So everytime 8MB of log data has been written, only then flush everything to program.log
My current log4j2.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace" monitorInterval="5">
<Properties>
<Property name="log-path">/opt/job/log</Property>
</Properties>
<Appenders>
<RollingFile name="CONSOLE_C" fileName="${log-path}/program.log" immediateFlush="false" append="false"
filePattern="${log-path}/program-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [ %-5p ] [%5X{TId}] [%22X{Info}] [ %20c ] - %-m %n"/>
<Policies>
<SizeBasedTriggeringPolicy size="10240 KB" />
</Policies>
<DefaultRolloverStrategy max="15" />
</RollingFile>
<Async name="Async" bufferSize="8000" shutdownTimeout="100" >
<AppenderRef ref="CONSOLE_C"/>
</Async>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="CONSOLE_C" />
</Root >
</Loggers>
Although I am writing most of my data to program.log but it doesnt appear to be asynchronous. The log file is being continuously written to while I am using the application.
Is there something wrong that I am doing ?