logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sverre Moe <sverre....@gmail.com>
Subject Setting Log4jContextSelector programmatic in Main application
Date Mon, 15 Jan 2018 10:47:17 GMT
Using static initialization of two log4j properties on top of my main
application.

    static {
        System.setProperty("Log4jContextSelector",
"org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
        System.setProperty("log4j.configurationFactory",
"com.company.utils.LoggingConfigurationFactory");
    }

    private static Logger logger = LogManager.getLogger(MyApplication.class);


Seems I have to define Log4jContextSelector on the command line,
otherwise Log4j2 does not use Async logging.
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

I can add this to maven configuration so users don't have to think
about this when they are running the application, but I also don't
want developers to have to manually have to add this property in IDE
or command line. Will end up with developers who might get different
performance than our users when they develop, test and debug the
application.


/Sverre

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message