Spring log4j2配置

原创转载请注明出处:http://agilestyle.iteye.com/blog/2386997

 

Maven Dependency

Spring log4j2配置_第1张图片
 

web.xml



    
        contextConfigLocation
        classpath:spring/applicationContext*.xml
    

    
        isLog4jAutoInitializationDisabled
        false
    

    
        org.springframework.web.context.ContextLoaderListener
    

    
        org.apache.logging.log4j.web.Log4jServletContextListener
    

    
        appServlet
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:spring/springmvc.xml
        
        1
    
    
        appServlet
        /
    

    
        log4jServletFilter
        org.apache.logging.log4j.web.Log4jServletFilter
    
    
        log4jServletFilter
        /*
        REQUEST
        FORWARD
        INCLUDE
        ERROR
    

    
        CharacterEncodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        
        
            forceEncoding
            true
        
    
    
        CharacterEncodingFilter
        /*
    

    
        15
    

    
        index.html
    

 

log4j2.xml

Spring log4j2配置_第2张图片

Note:log4j2.xml必须在resources根目录下

 

比较完整的log4j2.xml配置模板






    
    
        
        
            
            
        
        
        
            
        
        
        
            
            
            
            
                
                
            
        

        
            
            
            
                
                
            
            
            
        
        
            
            
            
                
                
            
        
    

    
    
        
        
        
        
            
            
            
            
        
    

 

使用方式

 

Reference

http://www.cnblogs.com/hafiz/p/6170702.html

https://logging.apache.org/log4j/2.x/

 

 

你可能感兴趣的:(Spring)