티스토리 뷰

Web Development/Spring

log4j 설정

dev ms 2016. 10. 27. 11:46
반응형
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- 콘솔 로그 --> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %p [%c{5}] %m %n" /> </layout> </appender> <!-- 날짜별 로그 파일 생성 --> <appender name="rollingFile" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="저장위치/logs/log.log" /> <param name="Append" value="true" /> <!-- param name="MaxFileSize" value="100MB"/ --> <!-- param name="MaxBackupIndex" value="2"></param --> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %p [%C{10}] %m %n" /> </layout> </appender> <!-- 날짜별 로그 파일 생성 --> <appender name="springFile" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="저장위치/logs/spring.log" /> <param name="Append" value="true" /> <!-- param name="MaxFileSize" value="100MB"/ --> <!-- param name="MaxBackupIndex" value="2"></param --> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %p [%C{10}] %m %n" /> </layout> </appender> <!-- 날짜별 로그 파일 생성(에러만) --> <appender name="errFile" class="org.apache.log4j.DailyRollingFileAppender"> <param name="Threshold" value="ERROR" /> <param name="File" value="저장위치/logs/error.log" /> <param name="Append" value="true" /> <!-- param name="MaxFileSize" value="100MB"/ --> <!-- param name="MaxBackupIndex" value="2"></param --> <param name="DatePattern" value="'.'yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %5p [%C{1}] %m %n" /> </layout> </appender> <!-- 특정 패키지 출력 설정 --> <logger name="org.apache.ibatis"> <level value="INFO" /> </logger> <logger name="org.springframework"> <level value="INFO" /> <appender-ref ref="springFile" /> </logger> <logger name="java.sql"> <level value="INFO" /> </logger> <logger name="jdbc" > <level value="ERROR" /> </logger> <logger name="jdbc.sqlonly" > <level value="INFO" /> </logger> <!-- 기본 출력 설정 --> <root> <level value="INFO" /> <appender-ref ref="console" /> <appender-ref ref="errFile" /> <appender-ref ref="rollingFile" /> </root> </log4j:configuration>

log4j 설정 방법.
http://devofhwb.tistory.com/20


반응형

'Web Development > Spring' 카테고리의 다른 글

Springframework xml h2 database setting  (0) 2016.10.27
Spring DataSource Query Logging  (0) 2016.10.27
Spring Transaction  (0) 2016.10.27
@PreConstruct, @PostConstruct  (0) 2016.10.27
Spring interceptor request.setAttribute 전달  (0) 2016.10.27