2 Replies Latest reply on Feb 11, 2013 11:08 PM by Venkata P

    DailyRollingFileAppender and rolling logic

    Venkata P Newbie

      Hi,

       

      I have this problem with Jboss 5.1.GA running on few of our RHEL 6.x boxes. By default, all of our Jboss instances have DailyRollingFileAppender configured.

       

      I assumed that using this choice of Appender, the logs file - server.log would get rotated at midnight everyday but this does not seem to happen with our jboss instance.

       

      What I have noticed is that rotation does happen but only when first request of the day arrives (irrespective of when it arrives). If the first request arrives at 8:00 AM the next day, the rolling happens only then.

       

      My developers say that this is the default behaviour of Jboss and that is how it is supposed to work but according to jboss log4j documentation, they say that rolling happens at midnight.

       

      http://www.docjar.org/html/api/org/jboss/logging/jdk/handlers/DailyRollingFileHandler.java.html

       

      (Description is on line 83)

       

      Can somebody throw some light on how and when JBoss 5.1 is supposed to rotate logs when using DailyRollingFileAppender?

       

      Thank you,

      VP

        • 1. Re: DailyRollingFileAppender and rolling logic
          Peter Johnson Master

          This is how Log4J works - log files are rolled in a lazy fashion when the first log entry after the split point is written. So the first log entry after midnight will cause Log4J to rename the active log file (e.g. server.log) to a timstamped file name and create a new active log file with that new log entry. There is no timer within Log4J that would cause this to happen exactly at midnight (which would result in an active log file with no entries).

           

          Of course, if you want to force this action, you could write a Quartz job (or some other scheduler job) that runs a second after midnight and writes a log entry; that should force the rollover.

          • 2. Re: DailyRollingFileAppender and rolling logic
            Venkata P Newbie

            Thanks Peter for the response. I wonder why they say "Roll over at Midnight each day"  in the documentation. This led to the confusion.