Conditional logging with log4j

后端 未结 4 1571
渐次进展
渐次进展 2020-11-29 03:00

The web application on which I am working occasionally develops data integrity issues for some of the users. I\'d like to turn on trace level logging, but since we are deali

4条回答
  •  死守一世寂寞
    2020-11-29 03:31

    I make a workaround as follow

    Config your log target in log4j.xml like the following:

        
        
        
        
        
            
        
    
        
            
            
        
    
            
    
    

    create a customer logger method that append your target tag [trackfile]

    private void logfile(String msg) {
        logger.info("trackfile: " + msg);
    }
    

    log your information using the above method:

    logfile("your log message")
    

提交回复
热议问题