How to disable Spring logging DEBUG messages?

后端 未结 3 727
终归单人心
终归单人心 2020-11-28 09:28

I\'m working on a simple desktop app (not webapp).

Here is my log4j.properties:

log4j.rootCategory=INFO, stdout

log4j.appender.stdout=o         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 09:57

    You can disable all debug logs by just calling the below code at start of your application. And you can enable or disable at any point of time by setting log type.

    ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    logger.setLevel(Level.toLevel("error"));
    

提交回复
热议问题