You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Sam Beroz (JIRA)" <ji...@apache.org> on 2014/11/17 18:47:34 UTC
[jira] [Created] (LOG4J2-896) Thread System Initialization
Sam Beroz created LOG4J2-896:
--------------------------------
Summary: Thread System Initialization
Key: LOG4J2-896
URL: https://issues.apache.org/jira/browse/LOG4J2-896
Project: Log4j 2
Issue Type: New Feature
Affects Versions: 2.1
Environment: All
Reporter: Sam Beroz
Priority: Minor
Some appenders take longer than others to load, notably ones that have to make remote connections (waiting for the SyslogAppender to timeout is painful). I've noticed a pause in my application as log4j is being configured. This happens early since I have a static data member call LogManager.getLogger(). I was able to avoid the penalty but initializing the log system in a different thread:
private volatile static Logger LOGGER;
static{
Thread thread = new Thread(){
public void run() {
//This will initialize the log system which could incur a timeout cost if the logservice isn't reachable
//subsequent calls to the LOGGER will block until initialization is complete
//starting it here just gives it a head start
LOGGER = LogManager.getLogger(MyClass.class);
}
};
thread.setDaemon(true);
thread.start();
}
Could the logic backing LogManager.getLogger() be changed to do something similar in a future release? This seems like something that could be taken care of behind the scenes.
Thanks - Sam
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org