sometimes you need to configure the log4j to daily roll the log file, this will help when you trace an error happened in a specific day.
in your log4j.properties file create an appender of type DailyRollingFileAppender:
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
define the date pattern which will be used in naming the log files:
log4j.appender.R.DatePattern=’-'yyyy-MM-dd’.log’
define the path of your log files:
log4j.appender.R.File=log/application
and configure how logs should appear inside the file:
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L – %m%n
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L – %m%n
log4j.rootLogger=debug, stdout, R
now you will have a separate log file for every day and will be in path
log/application-yyyy-MM-dd.log
May 13, 2009 at 12:11 pm
Is there maybe something wrong with your log4j.appender.R.DatePattern value ?
Because I can make it work in my application with your date pattern. And even I can save th log4j.properties file, it’s said that:
Some characters cannot be mapped using “ISO-8859-1″ …
May 14, 2009 at 3:22 am
Already found it… Just problem with quote…