Skip to content
정명주(myeongju.jung) edited this page Aug 10, 2018 · 2 revisions

Simple

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>

    <springProperty name="APPLICATION_NAME" source="spring.application.name" defaultValue="@project.name@"/>
    <springProperty name="VERSION" source="project.version" defaultValue="@project.version@"/>
    <springProperty name="APPKEY" source="lck.appKey" defaultValue="?????"/>
    <springProperty name="PHASE" source="common.env" defaultValue="unknown"/>

    <springProfile name="remote-logging">
        <appender name="lck-appender" class="???.LogAggregateAppender">
            <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>WARN</level>
            </filter>
            <param name="collectorUrl" value="http://aggregate.log.com"/>
            <param name="appKey" value="${APPKEY}"/>
            <param name="version" value="${VERSION}"/>
            <param name="logSource" value="${APPLICATION_NAME}"/>
            <param name="logType" value="${PHASE}"/>
            <param name="errorCodeType" value="default"/>
            <param name="enable" value="true"/>
            <param name="debug" value="false"/>
        </appender>
    </springProfile>

    <springProfile name="remote-logging">
        <root>
            <appender-ref ref="lck-appender"/>
        </root>
    </springProfile>
</configuration>

Custom

<configuration>
    <!-- reference : https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html -->
    <!-- logback 프로퍼티 설정 -->
    <property name="VERSION" value="@version@"/>
    <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
    <!-- 스프링 프로퍼티 설정 -->
    <springProperty name="APPLICATION_NAME" source="spring.application.name" defaultValue="@projectName@"/>
    <springProperty name="PHASE" source="phase" defaultValue="local"/>
    <springProperty name="SERVER_PORT" source="server.port" defaultValue="0"/>
    <springProperty name="MAX_HISTORY" source="logging.file.max-history" defaultValue="14"/>
    <springProperty name="ROOT_LEVEL" source="logging.level.root" defaultValue="INFO"/>
    <springProperty name="AMP_LEVEL" source="logging.level.com.amp" defaultValue="INFO"/>
    <springProperty name="SPRINGFRAMEWORK_LEVEL" source="logging.level.org.springframework" defaultValue="INFO"/>

    <!-- 스프링부트의 기본 설정을 포함 -->
    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />

    <!-- 스프링 프로필이 local이 아닌 경우 -->
    <springProfile name="!local">
        <!-- 파일 로그 Appender -->
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <encoder>
                <pattern>${FILE_LOG_PATTERN}</pattern>
            </encoder>
            <file>${LOG_FILE}</file>
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
                <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}</fileNamePattern>
                <maxHistory>${MAX_HISTORY}</maxHistory>
            </rollingPolicy>
        </appender>
    </springProfile>

    <springProfile name="beta, release">
        <!-- 운영용 LCK 설정? -->
    </springProfile>

    <!-- local 환경인 경우 console 출력을 사용한다. -->
    <springProfile name="local">
        <root level="${ROOT_LEVEL}">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>

    <!-- alpha 환경인 경우 file 출력을 사용한다. -->
    <springProfile name="alpha">
        <root level="${ROOT_LEVEL}">
            <appender-ref ref="FILE"/>
        </root>
    </springProfile>

    <springProfile name="performance">
        <root level="${ROOT_LEVEL}">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>

    <!-- beta, release 환경인 경우 file, LCK 출력을 사용한다. -->
    <springProfile name="beta, release">
        <root level="${ROOT_LEVEL}">
            <appender-ref ref="FILE"/>
            <appender-ref ref="LCK"/><!-- ?? -->
        </root>
    </springProfile>
</configuration>
Clone this wiki locally