hi
i use log4j for logging
i want the file that logs append to it , in every day be separated .for example
my logs for today input in 2010-04-20.log
and tomorrow in 2010-04-21.log file!!

or any way that i can understand that this log file related today and that log related yesterday!!
???????

Recommended Answers

All 2 Replies

You need to set the appender of the logger:
log4j.properties file:

log4j.logger.log_name=debug, F

log4j.appender.F=org.apache.log4j.DailyRollingFileAppender
log4j.appender.F.File=full_file_path/file.log
log4j.appender.F.DatePattern='.'yyyy-MM-dd

Every day the old file will be renamed according to the pattern, Look at the API for the class: org.apache.log4j.DailyRollingFileAppender and for the Logger class.

thank you for your reply :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.