logback配置单独打印日志

2018-03-16  本文已影响0人  wangpeng123
<appender name="test" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/test.log</file>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${LOG_PATH}/test.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>36</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}-%line - %msg%n</pattern>
        </encoder>
    </appender>
    <logger name="logname" level="INFO" additivity="false">
        <!-- <appender-ref ref="console" /> -->
        <appender-ref ref="test"/>
    </logger>



maven:
<slf4j.version>1.7.18</slf4j.version>
<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <!-- 代码直接调用common-logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <!-- 代码直接调用java.util.logging会被桥接到slf4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
上一篇下一篇

猜你喜欢

热点阅读