IT/development

[logback] logback 파일 생성

알 수 없는 사용자 2023. 5. 13. 19:10
반응형
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

    <property name="LOG_DIR" value="D:/applog/th-board2"/>
    <property name="LOG_FILE_NAME" value="th-board2"/>

    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]  %-3level [%logger{0}:%line] : %msg %n</pattern>
        </encoder>
    </appender>

    <appender name="console-sql" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]  %-3level [%logger{0}:%line] SQL : %n	%msg %n</pattern>
        </encoder>
    </appender>
	
    <!-- file appender 추가 -->
    <appender name="file" class="ch.qos.logback.core.FileAppender">
        <file>${LOG_DIR}/${LOG_FILE_NAME}.log</file>
        <encoder>
            <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}]  %-3level [%logger{0}:%line] : %msg %n</pattern>
        </encoder>
    </appender>

    <logger name="jdbc" level="OFF"/>
    <!-- sqlonly 레벨 수정-->
    <logger name="jdbc.sqlonly" level="DEBUG"/>
    <logger name="jdbc.sqltiming" level="DEBUG"/>
    <logger name="jdbc.audit" level="OFF"/>
    <logger name="jdbc.resultset" level="OFF"/>
    <!-- 쿼리 결과를 테이블 형식으로 볼려면 resultsettable 레벨 수정 -->
    <logger name="jdbc.resultsettable" level="DEBUG"/>
    <logger name="jdbc.connection" level="OFF"/>

    <root level="INFO">
        <appender-ref ref="console" />
        <!-- 위에서 추가한 file appender를 ref에 추가 -->
        <appender-ref ref="file" />
    </root>
</configuration>

반응형