What is right way to supply initialization for log4j2 in a Spring MVC Webapp using Java Config and no web.xml?

前端 未结 3 836
青春惊慌失措
青春惊慌失措 2021-01-22 15:59

I have a Spring MVC Web App (4.0) with log4j2. This webapp uses no web.xml and takes care of configuration through Java Config. Log4j2 configuration needs to take plac

3条回答
  •  猫巷女王i
    2021-01-22 16:45

    I believe you can reconfigure log4j2 to a new config file during runtime like this.

         LoggerContext context = (LoggerContext)LogManager.getContext(false);
         context.setConfigLocation(URI.create("path to file"));
         context.reconfigure();
    

    Could just add this to your onStartup.

提交回复
热议问题