Uploaded image for project: 'integration-packaging'
  1. integration-packaging
  2. INTPAK-199

Karaf log file rotation not using desired file rotation scheme

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • None

      I used karaf to generate some test logs, via:

      opendaylight-user@root>log:load-test --messaged 500000 --threads 10

      I monitored the karaf log rotation, as follows:

      ()[odl@overcloud-controller-2 /var/log/opendaylight]$ while true; do ls -lhrt karaf.lo*; echo; sleep 1; done;

      To make it a bit easier to see what was going on, I truncated the karaf.log.1 file to 10 bytes, and karaf.log.2 to 20 bytes.

      The expectation is that karaf.log would be rotated to karaf.log1, karaf.log1 would be rotated to karaf.log2, which is referred to as "fixed window strategy"

      Reference:
      http://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender

      Take a look at the "Rollover stategies section"

      Instead, we see that karaf.log is rotated to karaf.log.2

      rw-rr-. 1 odl odl 10 Aug 24 17:52 karaf.log.1
      rw-rr-. 1 odl odl 20 Aug 24 17:52 karaf.log.2
      rw-rr-. 1 odl odl 997M Aug 24 17:52 karaf.log

      rw-rr-. 1 odl odl 10 Aug 24 17:52 karaf.log.1
      rw-rr-. 1 odl odl 20 Aug 24 17:52 karaf.log.2
      rw-rr-. 1 odl odl 1008M Aug 24 17:52 karaf.log

      rw-rr-. 1 odl odl 10 Aug 24 17:52 karaf.log.1
      rw-rr-. 1 odl odl 20 Aug 24 17:52 karaf.log.2
      rw-rr-. 1 odl odl 1020M Aug 24 17:52 karaf.log

      rw-rr-. 1 odl odl 20 Aug 24 17:52 karaf.log.1
      rw-rr-. 1 odl odl 1.1G Aug 24 17:53 karaf.log.2
      rw-rr-. 1 odl odl 7.7M Aug 24 17:53 karaf.log

      The problem is that fileIndex defaults to "max". For the desired behavior, fileIndex should be set to "min".

      I have tested a fix, will push a patch shortly.

            vpickard Victor Pickard
            vpickard Victor Pickard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: