Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1855

Add an optional random delay in TimeBasedTriggeringPolicy

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.8.1
    • Fix Version/s: 2.9.0
    • Component/s: Appenders
    • Labels:
      None

      Description

      When there are lots of JVM on the same physical host configured to rolling their log file with a TimeBasedTriggeringPolicy, it will create a temporary load that can impact the behavior of the applications since all JVM will roll and compress the old file at the same time

      The purpose of this enhancement is to add an additional property on TimeBasedTriggeringPolicy to delay the rolling by a random amount of time to avoid that massive simultaneous rolling.

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user m-anthony opened a pull request:

          https://github.com/apache/logging-log4j2/pull/68

          LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy

          https://issues.apache.org/jira/browse/LOG4J2-1855

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/m-anthony/logging-log4j2 master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/logging-log4j2/pull/68.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #68


          commit 648274bb80693729cc3d5e43f67642dc44013c8a
          Author: Anthony MAIRE <maire.anthony@gmail.com>
          Date: 2017-03-23T13:43:04Z

          LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy

          commit 6235f81e819255c2d26338946a65bf3ee8b4ee42
          Author: amaire <amaire@smart-trade.net>
          Date: 2017-03-23T14:01:03Z

          formatting: change tabs to spaces


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user m-anthony opened a pull request: https://github.com/apache/logging-log4j2/pull/68 LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy https://issues.apache.org/jira/browse/LOG4J2-1855 You can merge this pull request into a Git repository by running: $ git pull https://github.com/m-anthony/logging-log4j2 master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/logging-log4j2/pull/68.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #68 commit 648274bb80693729cc3d5e43f67642dc44013c8a Author: Anthony MAIRE <maire.anthony@gmail.com> Date: 2017-03-23T13:43:04Z LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy commit 6235f81e819255c2d26338946a65bf3ee8b4ee42 Author: amaire <amaire@smart-trade.net> Date: 2017-03-23T14:01:03Z formatting: change tabs to spaces
          Hide
          Anthony Maire Anthony Maire added a comment -
          Show
          Anthony Maire Anthony Maire added a comment - Pull Request : https://github.com/apache/logging-log4j2/pull/68
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user jvz commented on a diff in the pull request:

          https://github.com/apache/logging-log4j2/pull/68#discussion_r109315499

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java —
          @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) {

          • Creates a TimeBasedTriggeringPolicy.
          • @param interval The interval between rollovers.
          • @param modulate If true the time will be rounded to occur on a boundary aligned with the increment.
            + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds)
          • @return a TimeBasedTriggeringPolicy.
            */
            @PluginFactory
            public static TimeBasedTriggeringPolicy createPolicy(
            @PluginAttribute("interval") final String interval,
          • @PluginAttribute("modulate") final String modulate) {
            + @PluginAttribute("modulate") final String modulate,
            + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) {
              • End diff –

          Instead of adding a new param to the factory method, do you think you could convert this to a builder and deprecate this method? This way, users who have used the factory method programmatically will not have an API change break their config, and this way we can also use the type conversion support to simplify the builder/factory as it is.

          Show
          githubbot ASF GitHub Bot added a comment - Github user jvz commented on a diff in the pull request: https://github.com/apache/logging-log4j2/pull/68#discussion_r109315499 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java — @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) { Creates a TimeBasedTriggeringPolicy. @param interval The interval between rollovers. @param modulate If true the time will be rounded to occur on a boundary aligned with the increment. + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds) @return a TimeBasedTriggeringPolicy. */ @PluginFactory public static TimeBasedTriggeringPolicy createPolicy( @PluginAttribute("interval") final String interval, @PluginAttribute("modulate") final String modulate) { + @PluginAttribute("modulate") final String modulate, + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) { End diff – Instead of adding a new param to the factory method, do you think you could convert this to a builder and deprecate this method? This way, users who have used the factory method programmatically will not have an API change break their config, and this way we can also use the type conversion support to simplify the builder/factory as it is.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user garydgregory commented on a diff in the pull request:

          https://github.com/apache/logging-log4j2/pull/68#discussion_r109315804

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java —
          @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) {

          • Creates a TimeBasedTriggeringPolicy.
          • @param interval The interval between rollovers.
          • @param modulate If true the time will be rounded to occur on a boundary aligned with the increment.
            + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds)
          • @return a TimeBasedTriggeringPolicy.
            */
            @PluginFactory
            public static TimeBasedTriggeringPolicy createPolicy(
            @PluginAttribute("interval") final String interval,
          • @PluginAttribute("modulate") final String modulate) {
            + @PluginAttribute("modulate") final String modulate,
            + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) {
              • End diff –

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user garydgregory commented on a diff in the pull request: https://github.com/apache/logging-log4j2/pull/68#discussion_r109315804 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java — @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) { Creates a TimeBasedTriggeringPolicy. @param interval The interval between rollovers. @param modulate If true the time will be rounded to occur on a boundary aligned with the increment. + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds) @return a TimeBasedTriggeringPolicy. */ @PluginFactory public static TimeBasedTriggeringPolicy createPolicy( @PluginAttribute("interval") final String interval, @PluginAttribute("modulate") final String modulate) { + @PluginAttribute("modulate") final String modulate, + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) { End diff – +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user m-anthony commented on a diff in the pull request:

          https://github.com/apache/logging-log4j2/pull/68#discussion_r109361653

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java —
          @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) {

          • Creates a TimeBasedTriggeringPolicy.
          • @param interval The interval between rollovers.
          • @param modulate If true the time will be rounded to occur on a boundary aligned with the increment.
            + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds)
          • @return a TimeBasedTriggeringPolicy.
            */
            @PluginFactory
            public static TimeBasedTriggeringPolicy createPolicy(
            @PluginAttribute("interval") final String interval,
          • @PluginAttribute("modulate") final String modulate) {
            + @PluginAttribute("modulate") final String modulate,
            + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) {
              • End diff –

          OK I will do that :+1:

          Show
          githubbot ASF GitHub Bot added a comment - Github user m-anthony commented on a diff in the pull request: https://github.com/apache/logging-log4j2/pull/68#discussion_r109361653 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java — @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) { Creates a TimeBasedTriggeringPolicy. @param interval The interval between rollovers. @param modulate If true the time will be rounded to occur on a boundary aligned with the increment. + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds) @return a TimeBasedTriggeringPolicy. */ @PluginFactory public static TimeBasedTriggeringPolicy createPolicy( @PluginAttribute("interval") final String interval, @PluginAttribute("modulate") final String modulate) { + @PluginAttribute("modulate") final String modulate, + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) { End diff – OK I will do that :+1:
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user m-anthony commented on a diff in the pull request:

          https://github.com/apache/logging-log4j2/pull/68#discussion_r109441172

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java —
          @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) {

          • Creates a TimeBasedTriggeringPolicy.
          • @param interval The interval between rollovers.
          • @param modulate If true the time will be rounded to occur on a boundary aligned with the increment.
            + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds)
          • @return a TimeBasedTriggeringPolicy.
            */
            @PluginFactory
            public static TimeBasedTriggeringPolicy createPolicy(
            @PluginAttribute("interval") final String interval,
          • @PluginAttribute("modulate") final String modulate) {
            + @PluginAttribute("modulate") final String modulate,
            + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) {
              • End diff –

          Done

          Show
          githubbot ASF GitHub Bot added a comment - Github user m-anthony commented on a diff in the pull request: https://github.com/apache/logging-log4j2/pull/68#discussion_r109441172 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java — @@ -84,15 +91,18 @@ public boolean isTriggeringEvent(final LogEvent event) { Creates a TimeBasedTriggeringPolicy. @param interval The interval between rollovers. @param modulate If true the time will be rounded to occur on a boundary aligned with the increment. + * @param maxRandomDelay If non-zero the rolling will be delayed by a random amount of time, up to the specified value (in seconds) @return a TimeBasedTriggeringPolicy. */ @PluginFactory public static TimeBasedTriggeringPolicy createPolicy( @PluginAttribute("interval") final String interval, @PluginAttribute("modulate") final String modulate) { + @PluginAttribute("modulate") final String modulate, + @PluginAttribute("maxRandomDelay") final int maxRandomDelay) { End diff – Done
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 648274bb80693729cc3d5e43f67642dc44013c8a in logging-log4j2's branch refs/heads/master from Anthony Maire
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=648274b ]

          LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy

          Show
          jira-bot ASF subversion and git services added a comment - Commit 648274bb80693729cc3d5e43f67642dc44013c8a in logging-log4j2's branch refs/heads/master from Anthony Maire [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=648274b ] LOG4J2-1855 Add an optional random delay in TimeBasedTriggeringPolicy
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6499f5d47654771f4ea770f168f55d7a07d81c13 in logging-log4j2's branch refs/heads/master from Anthony Maire
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=6499f5d ]

          LOG4J2-1855 Switch to builder pattern to keep binary compatibility

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6499f5d47654771f4ea770f168f55d7a07d81c13 in logging-log4j2's branch refs/heads/master from Anthony Maire [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=6499f5d ] LOG4J2-1855 Switch to builder pattern to keep binary compatibility
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit b1b95d80aa8759a6149638764e24c5ca60b7fc35 in logging-log4j2's branch refs/heads/master from Matt Sicker
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=b1b95d8 ]

          Add changelog entry for LOG4J2-1855

          Show
          jira-bot ASF subversion and git services added a comment - Commit b1b95d80aa8759a6149638764e24c5ca60b7fc35 in logging-log4j2's branch refs/heads/master from Matt Sicker [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=b1b95d8 ] Add changelog entry for LOG4J2-1855
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/logging-log4j2/pull/68

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/logging-log4j2/pull/68
          Hide
          jvz Matt Sicker added a comment -

          Thanks for the PR! Merged to master. Please verify and close. I'll add a note in the manual, too.

          Show
          jvz Matt Sicker added a comment - Thanks for the PR! Merged to master. Please verify and close. I'll add a note in the manual, too.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit ca86737d692bf574abb92fbcf8911fb556df9c4d in logging-log4j2's branch refs/heads/master from Matt Sicker
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=ca86737 ]

          LOG4J2-1855: Add docs about maxRandomDelay

          Show
          jira-bot ASF subversion and git services added a comment - Commit ca86737d692bf574abb92fbcf8911fb556df9c4d in logging-log4j2's branch refs/heads/master from Matt Sicker [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=ca86737 ] LOG4J2-1855 : Add docs about maxRandomDelay

            People

            • Assignee:
              jvz Matt Sicker
              Reporter:
              Anthony Maire Anthony Maire
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development