How can you find what URL was used in log4j default initialization?

后端 未结 4 445
执笔经年
执笔经年 2021-01-03 06:44

Log4j default initialization goes through a procedure to find and use a URL to configure with. Afterward, how can you find out what URL was ultimately used, without having

4条回答
  •  臣服心动
    2021-01-03 07:13

    If you can setup your own Configurator you can do something like that:

    Setup the JAVA system property : -Dlog4j.configuratorClass=MyConfigurator And then have your configurator instance intercepts the doConfigure call.

    public class MyConfigurator implements Configurator
    {
        public static URL url;
    
        @Override
        public void doConfigure(URL url, LoggerRepository repository)
        {
            this.url = url;
            new PropertyConfigurator().doConfigure(url, repository);
        }
    }
    

提交回复
热议问题