Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between log4j RollingFileAppender vs DailyRollingFileAppender

Tags:

java

log4j

What is the difference between log4j RollingFileAppender vs DailyRollingFileAppender? And why would I use one versus the other?

like image 794
Bill Avatar asked May 04 '11 14:05

Bill


People also ask

What is RollingFileAppender in log4j?

RollingFileAppender extends FileAppender to backup the log files when they reach a certain size. The log4j extras companion includes alternatives which should be considered for new deployments and which are discussed in the documentation for org. apache. log4j. rolling.

How do I use RollingFileAppender?

If using RollingFileAppender , then use TimeBasedRollingPolicy to specify when to roll over log files based on date time. Notice the FileNamePattern property. It defines the name pattern for rolled over files. In given example, it will rename the rollover log files with date-month in log file name.

What is TimeBasedRollingPolicy?

Class TimeBasedRollingPolicy It basically specifies the name of the rolled log files. The value FileNamePattern should consist of the name of the file, plus a suitably placed %d conversion specifier. The %d conversion specifier may contain a date and time pattern as specified by the SimpleDateFormat class.


1 Answers

Reading http://www.mail-archive.com/[email protected]/msg08183.html

  • DailyRollingFileAppender - Rotates based on dateFormat
  • RollingFileAppender - Rotates based on a maximum file size.

Also check:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/RollingFileAppender.html

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html

like image 124
jotapdiez Avatar answered Sep 27 '22 22:09

jotapdiez