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