All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tsurei.simple-bg-cli.1.1.1-RELEASE.source-code.shitsurei-log-config.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8"?>

<configuration scan="true" scanPeriod="60 seconds" debug="false"
               xmlns="http://ch.qos.logback/xml/ns/logback"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
    <!--  日志存储位置  -->
    <springProperty scope="context" name="logPath" source="log.path" defaultValue="logDir"/>
    <property name="log.filepath" value="${logPath}"/>
    <!--  日志格式  -->
    <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{100} %t %msg %n"/>

    <!-- 彩色日志依赖的渲染类 -->
    <conversionRule conversionWord="levelColor" converterClass="com.echola.common.config.logback.LevelColorful"/>
    <conversionRule conversionWord="loggerColor" converterClass="com.echola.common.config.logback.LoggerColorful"/>
    <conversionRule conversionWord="threadColor" converterClass="com.echola.common.config.logback.ThreadColorful"/>
    <property name="log.colorful.pattern"
              value="%d{yyyy-MM-dd HH:mm:ss.SSS} %threadColor([%thread]) %levelColor(%-5level) %loggerColor(%logger{100}) %t %msg %n"/>


    <!--  定义日志输出媒介:控制台  -->
    <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
        <!--  具体格式化输出定义  -->
        <encoder>
            <pattern>${log.colorful.pattern}</pattern>
        </encoder>
    </appender>

    <!--  定义日志输出媒介:文件  -->
    <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.filepath}/debug.log</file>
        <!--  定义滚动策略  -->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--  按小时生成,文件后缀名为gz会自动打包  -->
            <fileNamePattern>${log.filepath}/debug-%d{yyyy-MM-dd_HH}.log</fileNamePattern>
            <!--  最大保存天数  -->
            <maxHistory>10</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
        <!--  过滤器,只保留DEBUG级别的日志  -->
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>

    <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.filepath}/info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.filepath}/info-%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>20</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>

    <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.filepath}/error.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.filepath}/error-%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
    </appender>

    <!--  根日志记录器  -->
    <root level="INFO">
        <appender-ref ref="consoleAppender"/>
        <appender-ref ref="debugAppender"/>
        <appender-ref ref="infoAppender"/>
        <appender-ref ref="errorAppender"/>
    </root>

    <!--  自定义包日志记录器  -->
    <!--<logger name="com.echola" level="TRACE">
        <appender-ref ref="consoleAppender"/>
        <appender-ref ref="debugAppender"/>
        <appender-ref ref="infoAppender"/>
        <appender-ref ref="errorAppender"/>
    </logger>-->
</configuration>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy