slf4j+logback

MAVEN-主pom.xml文件
		<slf4j.version>1.7.6</slf4j.version>  
		<logback.version>1.1.1</logback.version> 

		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>${logback.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
	

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

    private final static Logger logger = LoggerFactory.getLogger(TestBankInvoker.class);

logger.debug("debug");



注意使用slf4j+logback,要把log4j相关的jar去除;
在maven的子工程中test/resources目录下面,可以加入logback.xml可以在JunitTest生效;
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
		<encoder charset="GBK">
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
			</pattern>
		</encoder>
	</appender>
	<root level="INFO">
		<appender-ref ref="stdout" />
	</root>
</configuration> 

你可能感兴趣的:(logback)