log4j2: Location for setting Log4jContextSelector system property for asynchronous logging

前端 未结 4 1915
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 17:45

I am attempting to set up asynchronous logging (for performance reasons) within REST web methods that currently run in a liberty profile server.

In order to do this, I h

4条回答
  •  渐次进展
    2021-02-05 18:23

    Log4j got initialized before calling the main method. So it's unable to pick your property Log4jContextSelector from the system and by default, it works synchronously.

    To verify same: remove disruptor dependency, If your project is still going up then it's not getting async.

    If you add property via -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector then after removing disruptor project will not go up.

    If you are using tomcat then add system properties in catalina.properties. And don't forget to use immediateFlush="false".

提交回复
热议问题