Log4j1 升级到 Log4j2

主要简介:

        slf4j-api:java日志框架抽象接口,业务代码使用日志时调用SLF4J抽象类,与日志实现框架(log4j/logback)解耦。

        log4j-slf4j-impl: log4j对slf4j抽象接口具体实现类

        log4j-api:log4j 接口模块

        log4j-core:log4j实现模块

        log4j-1.2-api:兼容log4j1版本模块

添加Maven依赖

		
	
        2.17.1
		1.7.25
	

 
 
   
		org.slf4j
		slf4j-api
		${org.slf4j.version}
	 
	
	 
	
	    org.apache.logging.log4j
	    log4j-slf4j-impl
	    ${log4j.version}
	
	
	
	  org.apache.logging.log4j
	  log4j-api
	  ${log4j.version}
	
	
	
		org.apache.logging.log4j
		log4j-core
		${log4j.version}
	
	 
	
	    org.apache.logging.log4j
	    log4j-1.2-api
	    ${log4j.version}
	

添加Log4j2.xml配置文件




    
        log4j2test
        
        ${sys:catalina.home}/logs/${APP_NAME}
        
        [%t][%d{yyyyMMdd HH:mm:ss}][%-5p][%c{3}:%L] - %m%n
        info
    


    
        
            
        
 
        
            
            
                
                
            

            
            
            
            
                
            
            
        
 
    
    
    	
    	
    	
    	
        
            
            
        
    

参考:

SLF4J Manual

Log4j – Migrating from Log4j 1.x to 2.x

Log4j – API Separation

Log4j – Configuring Log4j 2

你可能感兴趣的:(log4j,apache,java)