Setting logback.xml path programmatically

后端 未结 5 1135
我在风中等你
我在风中等你 2020-12-02 13:27

I know I can set the logback.xml path like this:

Specifying the location of the default configuration file as a system property

You may specif

5条回答
  •  没有蜡笔的小新
    2020-12-02 13:52

    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.reset();
    JoranConfigurator configurator = new JoranConfigurator();
    InputStream configStream = FileUtils.openInputStream(logbackPropertiesUserFile);
    configurator.setContext(loggerContext);
    configurator.doConfigure(configStream); // loads logback file
    configStream.close();
    

提交回复
热议问题