1. Priorities
로깅 레벨은 다음과 같다.
DEBUG > INFO > WARN < ERROR < FATAL
|
Example
log4j.rootLogger=Level, Appender, Appender, …
log4j.logger.Package.Package.Class=Level
2. Appenders
|
Example
log4j.appender.Appender=org.apache.log4j.Name
……
Example – DailyRollingFileAppender
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#월단위 log4j.appender.logfile.DatePattern=’.'yyyy-MM
#주단위 log4j.appender.logfile.DatePattern=’.'yyyy-MM-ww
#12시간단위 log4j.appender.logfile.DatePattern=’.'yyyy-MM-dd-a
#시간단위 log4j.appender.logfile.DatePattern=’.'yyyy-MM-dd-HH
#분단위 log4j.appender.logfile.DatePattern=’.'yyyy-MM-dd-HH-mm
…
Example – RollingFileAppender
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.MaxFileSize=512KB
log4j.appender.logfile.MaxBackupIndex=3
3. Layouts
|
Example
log4j.appender.Appender.layout=org.apache.log4j.Name
…
Example – SimpleLayout
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
…
Example – HTMLLayout
log4j.appender.stdout.layout=org.apache.log4j.HTMLLayout
…
Example – TTCCLayout
log4j.appender.stdout.layout=org.apache.log4j.TTCCLayout
4. PatternLayout
|
5. Format Modifier
|
6. 전체 예
log4j.rootLogger=WARN, stdout, logfile, socket
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p [%-4t] %-25.25c %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${java.io.tmpdir}/myapp.log
log4j.appender.logfile.MaxFileSize=512KB
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %r [%t] %-5p %c %x – %m%n
log4j.appender.socket=org.apache.log4j.net.SocketHubAppender
log4j.appender.socket.port=10005
log4j.appender.socket.locationInfo=true
log4j.logger.com.my.app=DEBUG
'프로그램 > Etc' 카테고리의 다른 글
[기타] 구글날씨API 도시별 정보 (0) | 2014.02.17 |
---|---|
[Spring] Spring JDBC – JdbcTemplate 사용 예제 (0) | 2014.02.16 |
[Spring] DataSource 얻기 (0) | 2014.02.15 |
[iBatis] sql문에 한글 추가시, 한글 깨짐현상 (0) | 2014.02.12 |
[VisualSVN] 백업 및 복구 (0) | 2014.01.04 |