What is the difference between log4j RollingFileAppender
vs DailyRollingFileAppender
?
And why would I use one versus the other?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With