log4j2的xml配置

阅读更多

 

参考地址:

官网: https://logging.apache.org/log4j/2.x/manual/configuration.html

 

maven的配置:


	4.0.0

	org.kanpiaoxue
	logtest
	0.0.1-SNAPSHOT
	jar

	logtest
	http://maven.apache.org

	
		UTF-8
		1.8
		1.8

		2.7
	

	

		
		
				com.lmax
				disruptor
				3.3.6
			
		
			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}
		
		
			org.apache.logging.log4j
			log4j-web
			${log4j.version}
			runtime
		
		
			org.apache.logging.log4j
			log4j-jcl
			${log4j.version}
		
		
			org.apache.logging.log4j
			log4j-slf4j-impl
			${log4j.version}
		

		

		
			junit
			junit
			3.8.1
			test
		
	

 

 

package org.kanpiaoxue.logtest.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogAction {
	private static final Logger LOGGER = LoggerFactory.getLogger(LogAction.class);

	public static void main(String[] args) {
		for (int i = 0; i < 10; i++) {

			LOGGER.trace("Hello World!");
			LOGGER.debug("Hello World!");
			LOGGER.info("Hello World!");
			LOGGER.warn("Hello World!");
			LOGGER.error("Hello World!");
			LOGGER.error("Hello World! {}", System.getenv("LOG_HOME"));
		}
	}
}

 

appender地址:http://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender

 



	
	
                test
		
		 %msg%xEx%n
		]]>
		
	

	

		
			
		

		
			
			
				
			
			
		

	

	
		
		
			
			
		

		
		
			
			
		
	

 

你可能感兴趣的:(log4j2的xml配置)