How to change root logging level programmatically for logback

前端 未结 7 1318
猫巷女王i
猫巷女王i 2020-11-29 16:58

I have the following logback.xml file:

 

          


        
7条回答
  •  悲哀的现实
    2020-11-29 17:30

    I think you can use MDC to change logging level programmatically. The code below is an example to change logging level on current thread. This approach does not create dependency to logback implementation (SLF4J API contains MDC).

    
      
        LOG_LEVEL
        DEBUG
        
          TRACE
          TRACE
        
        
          DEBUG
          DEBUG
        
        
          INFO
          INFO
        
        
          WARN
          WARN
        
        
          ERROR
          ERROR
        
      
      ......
    
    
    MDC.put("LOG_LEVEL", "INFO");
    

提交回复
热议问题