른록노트

[Java] log4j 설정 본문

Programming/[Java]

[Java] log4j 설정

른록 2018. 9. 22. 04:04

@ 소스


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

<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">


    <!-- Appenders -->

    <appender name="console" class="org.apache.log4j.ConsoleAppender">

        <param name="Target" value="System.out" />

        <layout class="org.apache.log4j.PatternLayout">

            <!--ConversionPattern은 로그가 찍히는 패턴-->

            <param name="ConversionPattern" value="%t> [%d{yyyy-MM-dd HH:mm:ss}] [%c{1}] [%L] [%p] %m %n"/>  

        </layout>

    </appender>

    <appender name="dailyout" class="org.apache.log4j.DailyRollingFileAppender">  

        <!-- 이것은 날짜별로  로그를 남김. 파일명.확장자.DatePattern으로 정의 함-->  

        <param name="file" value="./logs/dailyout.log"/>  

        <param name="Append" value="true"/>  

        <param name="DatePattern" value="'.'yyMMdd"/>  

        <layout class="org.apache.log4j.PatternLayout"> 

            <param name="ConversionPattern" value="%t> [%d{yyyy-MM-dd HH:mm:ss}] [%c{1}] [%L] [%p] %m %n"/>  

        </layout>  

    </appender>  


    <!-- Application Loggers -->

    <logger name="base">

        <level value="debug" />

         <appender-ref ref="dailyout" />

    </logger>

    <logger name="core">

        <level value="debug" />

         <appender-ref ref="dailyout" />

    </logger>

    <logger name="org">

        <level value="info" />

        <appender-ref ref="console" />

    </logger>


    <!-- Root Logger -->

    <root>

        <priority value="debug"/>

        <appender-ref ref="console" />

    </root>

</log4j:configuration>



참고사이트


반응형
Comments