Log4j 2
  1. Log4j 2
  2. LOG4J2-43

Allow DailyRollingFile appender to rollover programmatically

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:
      None

      Description

      Allow DailyRollingFile appender to rollover programmatically without appending any new log event.

      This will allow log file rollover, in case there's no messages to be logged for a long time,
      but the current log file needs to be backed up.

      I think making the rollOver method public would be sufficient

        Issue Links

          Activity

          Ralph Goers made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Duplicate [ 3 ]
          Hide
          Ralph Goers added a comment -

          Marking this as a duplicate since this was really reported against Log4j 1.x.

          Show
          Ralph Goers added a comment - Marking this as a duplicate since this was really reported against Log4j 1.x.
          Ralph Goers made changes -
          Field Original Value New Value
          Link This issue duplicates LOG4J2-89 [ LOG4J2-89 ]
          Hide
          Lukasz Wielek added a comment -

          Right, it's 1.x code.

          Are you considering a kind of timer/thread that would fire rollover at certain time ?
          I think that the DatePattern would be sufficent, to configure 'auto-rollover'.

          Show
          Lukasz Wielek added a comment - Right, it's 1.x code. Are you considering a kind of timer/thread that would fire rollover at certain time ? I think that the DatePattern would be sufficent, to configure 'auto-rollover'.
          Hide
          Ralph Goers added a comment -

          I have a suspicion the previous comment is for Log4J 1.x?

          I expect a programmatic call will be required to ultmately allow the rollover via JMX. However, it would also make sense to be able to provide configurable guidance on when a rollover must be forced.

          Show
          Ralph Goers added a comment - I have a suspicion the previous comment is for Log4J 1.x? I expect a programmatic call will be required to ultmately allow the rollover via JMX. However, it would also make sense to be able to provide configurable guidance on when a rollover must be forced.
          Hide
          Lukasz Wielek added a comment -

          Looks like making rollOver public will not be sufficient.
          I think it is required to add forceRollOver method which will include code similar to subAppend method:

          public void forceRollOver()
          {
          long n = System.currentTimeMillis();
          if (n >= nextCheck)
          {
          now.setTime;
          nextCheck = rc.getNextCheckMillis(now);
          try

          { rollOver(); }

          catch (IOException ioe)

          { LogLog.error("rollOver() failed.", ioe); }

          }
          }

          Show
          Lukasz Wielek added a comment - Looks like making rollOver public will not be sufficient. I think it is required to add forceRollOver method which will include code similar to subAppend method: public void forceRollOver() { long n = System.currentTimeMillis(); if (n >= nextCheck) { now.setTime ; nextCheck = rc.getNextCheckMillis(now); try { rollOver(); } catch (IOException ioe) { LogLog.error("rollOver() failed.", ioe); } } }
          Lukasz Wielek created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Lukasz Wielek
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development