BasicConfigurator replacement in log4j2

后端 未结 2 2165
旧时难觅i
旧时难觅i 2021-02-20 11:10

I am working on a log4j 1 to log4j 2 migration. Inside a AppConfigInitializer file we use something like this -

BasicConfigurator.configure(consoleAppender);


        
相关标签:
2条回答
  • 2021-02-20 11:42
    Configurator.initialize(new DefaultConfiguration());
    
    0 讨论(0)
  • 2021-02-20 11:47

    The solution above works, but since default log level is ERROR, not all logs are shown. Log level can be adjusted with Configurator.setRootLevel method:

        Configurator.initialize(new DefaultConfiguration());
        Configurator.setRootLevel(Level.INFO);
    
    0 讨论(0)
提交回复
热议问题