Logback 로그 파일 구성 템플릿

7608 단어 Speingcloud

<configuration debug="true" scan="true" scanPeriod="30 secondes">

    <property name="CONSOLE_APPENDER_NAME" value="CONSOLE"/>
    <property name="FILE_APPENDER_NAME" value="FILE"/>
    <property name="CONSOLE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSSS} - [Thread-%thread] -[level-%-5level] - [%class : %method : %line] -  %msg %n"/>
    <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSSS} - [Thread:%thread] - [level: %-5level] - [%class : %method : %line] - %msg %n"/>
    <property name="FILE_NAME_PATTERN" value="%d{yyyy-MM-dd}.%i.log"/>
    <property name="FILE_PATH" value="D:/Log/Test-Client-Log.log"/>
    <property name="ROOT_LEVEL" value="debug"/>

    <appender name="${CONSOLE_APPENDER_NAME}" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>${CONSOLE_LOG_PATTERN}pattern>
            <charset>UTF-8charset>
        encoder>
    appender>

    <appender name="${FILE_APPENDER_NAME}" class="ch.qos.logback.core.rolling.RollingFileAppender">
        
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${FILE_PATH}-${FILE_NAME_PATTERN}FileNamePattern>
            <MaxHistory>30MaxHistory>
            <maxFileSize>2MBmaxFileSize>
            <totalSizeCap>10MBtotalSizeCap>
        rollingPolicy>
        <encoder>
            <pattern>${FILE_LOG_PATTERN}pattern>
            <charset>UTF-8charset>
        encoder>
    appender>

    <root level="${ROOT_LEVEVL}">
        <appender-ref ref="${CONSOLE_APPENDER_NAME}"/>
        <appender-ref ref="${FILE_APPENDER_NAME}"/>
    root>

    <logger name="com.apache.ibatis" level="TRACE"/>
    <logger name="java.sql.Connection" level="DEBUG"/>
    <logger name="java.sql.PreparedStatement" level="DEBUG"/>
    <logger name="java.sql.Statement" level="DEBUG"/>
configuration>

탭은 모든 사용자 정의 변수를 집중적으로 설정하여 관리하기 편리하도록 한다.구체적인 라벨의 뜻은 참고하세요. - 해석.

좋은 웹페이지 즐겨찾기