Log4j 2
  1. Log4j 2
  2. LOG4J2-454

TimeBasedTriggeringPolicy should use event time millis

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta9
    • Fix Version/s: None
    • Component/s: Appenders
    • Labels:
      None

      Description

      In the TimeBasedTriggeringPolicy.java, it's using system current timestamp to compare with nextRollover time:
      Code:

              final long now = System.currentTimeMillis();
              if (now > nextRollover) { ... ....
      

      But I think, it should use the event time millis:
      Code:

      	final long now = event.getMillis();
      	if (now > nextRollover) {... ...
      

      According the event time millis, it can be System.currentTimeMillis or Message's timestamp if the message implements TimestampMessage.

      So I think the event.getMillis() would be the best choice for comparing with nextRollover time.

        Activity

        robin zhang tao created issue -
        Remko Popma made changes -
        Field Original Value New Value
        Description In the TimeBasedTriggeringPolicy.java, it's using system current timestamp to compare with nextRollover time:
        Code:
                final long now = System.currentTimeMillis();
                if (now > nextRollover) { ... ....

        But I think, it should use the event time millis:
        Code:
        final long now = event.getMillis();
        if (now > nextRollover) {... ...

        According the event time millis, it can be System.currentTimeMillis or Message's timestamp if the message implements TimestampMessage.

        So I think the event.getMillis() would be the best choice for comparing with nextRollover time.
        In the TimeBasedTriggeringPolicy.java, it's using system current timestamp to compare with nextRollover time:
        Code:
        {code}
                final long now = System.currentTimeMillis();
                if (now > nextRollover) { ... ....
        {code}

        But I think, it should use the event time millis:
        Code:
        {code}
        final long now = event.getMillis();
        if (now > nextRollover) {... ...
        {code}

        According the event time millis, it can be System.currentTimeMillis or Message's timestamp if the message implements TimestampMessage.

        So I think the event.getMillis() would be the best choice for comparing with nextRollover time.
        Remko Popma made changes -
        Assignee Remko Popma [ remkop@yahoo.com ]
        Remko Popma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        robin zhang tao made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Remko Popma
            Reporter:
            robin zhang tao
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development