반응형

log4j2.xml 에서 로그파일 저장, 년도/월별 폴더 생성 후 그 아래에 로그파일 일자시간별 생성 저장.

    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %5p [%c] %m%n" />
        </Console>
        <RollingFile name="file" fileName="./logs/file/all.log" 
                   filePattern="./logs/file/$${date:yyyy}/$${date:MM}/all_%d{yyyyMMddHH}.log">
                <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
                <Policies>
                        <TimeBasedTriggeringPolicy /><!-- Rotated everyday -->
                </Policies>
        </RollingFile>
    </Appenders>

 

<Loggers> 에서 <AppenderRef ref="file" > 이어야 파일로 저장. 

    <Loggers> 
       
        <Logger name="java.sql" level="off" additivity="false">
            <AppenderRef ref="console" />
        </Logger>
        <Logger name="egovframework" level="ERROR" additivity="false">
            <AppenderRef ref="console" />
            <AppenderRef ref="file"/> 
        </Logger>
        <Logger name="org.springframework" level="DEBUG" additivity="false">
            <AppenderRef ref="console" /> 
            <AppenderRef ref="file"/> 
        </Logger>


        <Logger name="jdbc.sqltiming" level="off" additivity="false">

            <AppenderRef ref="console" />
        </Logger>
        <Logger name="jdbc.resultsettable" level="off" additivity="false">
            <AppenderRef ref="console"/>
        </Logger>
        <Logger name="jdbc.sqlonly" level="info" additivity="false"> <!-- info / ERROR / DEBUG / off -->
            <AppenderRef ref="console"/>
        </Logger>

        <Root level="ERROR">
            <AppenderRef ref="console" />
        </Root>
    </Loggers>

 

반응형

+ Recent posts