使用slf4j
報(bào)錯(cuò)
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
-
slf4j
即簡(jiǎn)單日志門面(Simple Logging Facade for Java)瓣喊,不是具體的日志解決方案,它只服務(wù)于各種各樣的日志系統(tǒng)黔酥。 - 打印
slf4j
需要具體日志實(shí)現(xiàn)框架log4j
,log4j2
等 - 第三方框架使用
slf4j
方便使用者用自己的日志實(shí)現(xiàn)框架接管日志
寫第三方項(xiàng)目的時(shí)候可以使用日志實(shí)現(xiàn)框架做 Test
這里使用了 log4j2
做日志的實(shí)現(xiàn)框架
scope
設(shè)置了 test
打包的時(shí)候不會(huì)被打包進(jìn)去
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<excludes>
<exclude>**/log4j2.xml</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>