tags:

views:

25

answers:

1

Hi all,

I want to use log4j in my web application.I will like to setup the log4j in such a way that when the file reach a certain size, we start writing a new log files, making it easier to open and read. Can you please explain the setup of RollingFileAppender.

Thanks

A: 

Lots of examples on the internet, e.g. this creates a daily rolling log file that rolls over to log4jtest.log.2010-08-25 etc

# configure the root logger
log4j.rootLogger=INFO, DAILY

# configure the daily rolling file appender
log4j.appender.DAILY=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DAILY.File=/tmp/log4j/log4jtest.log
log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd
log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
log4j.appender.DAILY.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n
skaffman