配置SSH2项目里面的log4j流程(转)

1.配置web.xml文件

[html]  view plain  copy
  1.   
  2. <context-param>  
  3.     <param-name>log4jConfigLocationparam-name>  
  4.     <param-value>WEB-INF/log4j.propertiesparam-value>  
  5. context-param>  
  6.   
  7.   
  8. <context-param>  
  9.     <param-name>log4jRefreshIntervalparam-name>  
  10.     <param-value>60000param-value>  
  11. context-param>  
  12.   
  13.   
  14. <context-param>  
  15.     <param-name>webAppRootKeyparam-name>  
  16.     <param-value>homeparam-value>  
  17. context-param>  
  18.   
  19. <listener>  
  20.     <listener-class>org.springframework.web.util.Log4jConfigListenerlistener-class>  
  21. listener>  

2.log4j2.xml配置







     
        ${sys:catalina.home}/WebAppLogs/HHServices
        
    

    

        
        
        
        

        
        
            
            
            
            
        
        
        
            
            
        


        
        
            
                %5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n
            
            
                
                

            
            
                
                
                
            
        

        
        
            
                %5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n
            
            
                

                
                

            
            
                
                
            
        

        
        
            
                %5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n
            
            
                
            
            
                
                
            
        

        
        
            
                %5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n
            
            
                
            
            
                
                
            
        

        
        
            
                %5p [%t] %d{yyyy-MM-dd HH:mm:ss} (%F:%L) %m%n
            
            
                
            
            
                
            
        
    

    
        
        
        
            
            
            
            
            
            
            
        

        
        
        
        
        
        
        

    


参考:https://www.cnblogs.com/hyyq/p/7171227.html

 https://blog.csdn.net/japanstudylang/article/details/8902737

http://logging.apache.org/log4j/2.x/manual/configuration.html#XML

你可能感兴趣的:(java)