02-slf4j日志门面配置

slf4j与simple整合

POM

<dependencies>
    
    
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-apiartifactId>
        <version>1.7.32version>
    dependency>
	
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-simpleartifactId>
        <version>1.7.32version>
    dependency>
dependencies>

slf4j与 jdk14整合

POM

<dependencies>
    
    
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-apiartifactId>
        <version>1.7.32version>
    dependency>

    <dependency>
        <groupId>org.slf4jgroupId>
        
        <artifactId>slf4j-jdk14artifactId>
        <version>1.7.32version>
    dependency>
dependencies>

slf4j+logback

POM

<dependencies>
    
    
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-apiartifactId>
        <version>1.7.32version>
    dependency>

    
    <dependency>
        <groupId>ch.qos.logbackgroupId>
        <artifactId>logback-coreartifactId>
        <version>1.2.3version>
    dependency>

    
    <dependency>
        <groupId>ch.qos.logbackgroupId>
        <artifactId>logback-classicartifactId>
        <version>1.2.3version>
    dependency>
dependencies>

slf4j 与 log4j整合

<dependencies>
    
    
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-apiartifactId>
        <version>1.7.32version>
    dependency>

    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-log4j12artifactId>
        <version>1.7.32version>
    dependency>
dependencies>

log4j还需要配置log4j.properties文件:

log4j.rootLogger=DEBUG,CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n

slf4j 与log4j2整合

<dependencies>
    
    
    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-apiartifactId>
        <version>1.7.32version>
    dependency>

    <dependency>
        <groupId>org.slf4jgroupId>
        <artifactId>slf4j-log4j12artifactId>
        <version>1.7.32version>
    dependency>
    <dependency>
        <groupId>log4jgroupId>
        <artifactId>log4jartifactId>
        <version>1.2.17version>
    dependency>
dependencies>

你可能感兴趣的:(Java日志框架,单元测试,junit)