Logging server logs to one file and SQL logs to another

后端 未结 1 1936
Happy的楠姐
Happy的楠姐 2021-01-24 05:59

I want to log all server related logs (like startup and shutdown) to one file and all Hibernate SQL related logs to a different file using Log4J. I am trying to filter all irrel

1条回答
  •  情歌与酒
    2021-01-24 06:56

    You can do that if you use two different appenders, as is shown in the following configuration file (XML): 1

    
    
    
    
        
        
            
            
                
            
        
    
        
        
            
            
                
            
        
    
        
        
            
            
        
    
        
        
            
            
        
    
    
    

    Using categories (category), you can easily configure the appender destination (appender-ref) and if you want to log in the default appenders (additivity="false").


    Notes

    1. log4j look for the log4j.xml file automatically in the classpath of the application (the default package or resources directory)

    0 讨论(0)
提交回复
热议问题