美文网首页
logbak-spring.xml

logbak-spring.xml

作者: 赛亚人之神 | 来源:发表于2018-05-08 10:57 被阅读12次

    手册地址

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration scan="true" scanPeriod="60 seconds" debug="false">
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
        <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
        <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring}"/>
        <property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
        <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"/>
    
        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <charset>utf8</charset>
                <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度,%msg:日志消息,%n是换行符-->
                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
            </encoder>
        </appender>
        <!-- 按照每天生成日志文件 -->
        <appender name="TIME_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <encoder>
                <pattern>${FILE_LOG_PATTERN}</pattern>
                <charset>utf8</charset>
            </encoder>
            <file>${LOG_FILE}.log</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <!--日志文件输出的文件名 -->
                <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
                <maxHistory>30</maxHistory>
                <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                    <maxFileSize>100MB</maxFileSize>
                </timeBasedFileNamingAndTriggeringPolicy>
            </rollingPolicy>
        </appender>
        <!-- JRE -->
        <logger name="com.sun" level="ERROR" />
        <!-- NETFLIX -->
        <logger name="com.netflix" level="ERROR" />
        <!-- SPRING -->
        <logger name="org.springframework" level="info" />
        <!-- SWAGGER2 -->
        <logger name="springfox.documentation" level="ERROR" />
        <!-- TOMCAT -->
        <logger name="org.apache.catalina" level="ERROR" />
        <!-- MYBATIS -->
        <logger name="org.mybatis.spring" level="ERROR" />
        <!-- MONGODB -->
        <logger name="org.mongodb" level="DEBUG" />
        <!-- SQL -->
        <logger name="com.magic.platform.mapper.build.dao" level="${logger.level}" />
    
        <!--myibatis log configure-->
        <logger name="com.apache.ibatis" level="${logger.level}"/>
        <logger name="java.sql.Connection" level="${logger.level}"/>
        <logger name="java.sql.Statement" level="${logger.level}"/>
        <logger name="java.sql.PreparedStatement" level="${logger.level}"/>
    
        <!-- 业务日志输出级别 -->
        <logger name="com.magic.platform.core" level="${logger.level}" />
        <logger name="com.magic.platform.util" level="${logger.level}" />
        <logger name="com.magic.platform.support" level="${logger.level}" />
        <!--<logger name="com.magic.platform.auth" level="${logger.level}" />-->
        <!-- 系统日志输出级别 -->
        <root level="INFO">
            <appender-ref ref="CONSOLE" />
            <appender-ref ref="TIME_FILE" />
        </root>
    </configuration>
    

    相关文章

      网友评论

          本文标题:logbak-spring.xml

          本文链接:https://www.haomeiwen.com/subject/siyirftx.html