How do I configure log4j using log4j.xml to append to different log files based on class name?

后端 未结 2 1356
甜味超标
甜味超标 2020-12-13 19:21

I want to set up log4j so that all log meessages produced from classes under package com.foo.bar go to bar.log, and all the log meessages produced from classes under package

2条回答
  •  一整个雨季
    2020-12-13 19:35

    This is based on my answer to a similar question:

    
    
        
        
            
            
            
                
            
         
    
        
        
            
            
                
            
        
    
        
            
        
    
        
            
        
    
        
            
            
        
    
    

    If you add an appender-ref to the root element, it will also receive com.foo.bar etc messages. You can stop that by specifying 'additivity="false"' on the loggers.

提交回复
热议问题