12

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

2 Answers 2

24

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

7

On DailyRollingFileAppender the file is rolled over at a user chosen frequency, but on RollingFileAppender the file is rolled when the file reaches certain size.

4
  • 3
    Not necessarily, because you can create daily rolling appender using RollingFileAppender and it's rollingPolicy attribute, where you define how often to roll. See the log4j extras which provides lots of bugfixes to the 1.2 line and a few improvements.
    – soltysh
    Apr 1, 2014 at 9:54
  • Hi soltysh ! Can you please mention how we can proceed that kind of configuration. I have post a similar kind of question: stackoverflow.com/questions/27056481/… . Thanks.
    – Channa
    Nov 21, 2014 at 7:51
  • @pconcepcion How can one test daily rolling file appender in local system? Can't wait till midnight to check if rollover occurs or not?
    – Gaurav
    May 23, 2019 at 13:30
  • 1
    @gaurav I have not tested this, but I think you can either change the device hour, or maybe test with a different / shorter frecuency that will be probably more useful for testing. Jul 28, 2019 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.