Hi,

I am trying to configure async loggers for my application using log4j2. When I 
log my events .. They still seem to be synchronous. I see the log even flushed 
to the file immediately. I would have assumed, async loggers will hold the 
events till the buffer is full before flushing. How do I confirm if is actually 
doing asynchronous logging. Or please correct if I am missing something.

In my startup I have (for all async loggers).

-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
Also, have the disruptor 3.2.1 in the class path. I use slf4j and use the 
bridge to log to log4j2
This is my log4j2.xml (just using the one which the 
http://logging.apache.org/log4j/2.x/manual/appenders.html provides)


  1.  <?xml version="1.0" encoding="UTF-8"?>
  2.  <Configuration status="warn" name="MyApp" packages="">
  3.  <Appenders>
  4.  <RollingRandomAccessFile name="RollingRandomAccessFile" 
fileName="logs/app.log"
  5.  filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz" 
immediateFlush="false">
  6.  <PatternLayout>
  7.  <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
  8.  </PatternLayout>
  9.  <Policies>
  10. <TimeBasedTriggeringPolicy />
  11. <SizeBasedTriggeringPolicy size="250 MB"/>
  12. </Policies>
  13. </RollingRandomAccessFile>
  14. </Appenders>
  15. <Loggers>
  16. <Root level="error">
  17. <AppenderRef ref="RollingRandomAccessFile"/>
  18. </Root>
  19. </Loggers>
  20. </Configuration>

Thanks
-prashant

Reply via email to