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

Distinguish between partial and completed .gz archive file

    Details

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

      Description

      I have the following log configuration.

          <RollingRandomAccessFile name="RollingReqAppender"
              fileName="/usr/test/req.log"
              filePattern="/usr/test/req.log.%d{yyyy-MM-dd-HH}.%i.gz"
              immediateFlush="true" append="true">
              <PatternLayout>
                  <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS Z}%m%n</Pattern>
              </PatternLayout>
              <Policies>
                  <SizeBasedTriggeringPolicy size="500 MB"/>
                  <TimeBasedTriggeringPolicy interval="1" modulate="true" />
              </Policies>
          </RollingRandomAccessFile>
      

      When the log is rolled over (based on time or size), it is gzipped. Gzipping the file takes some time (seconds to minutes depending on load). The problem is that the file is gzipped in place, and while it is being gzipped, the partially gzipped file is stored in the same folder with the same name as the final gzip file. e.g.: /usr/test/req.log.2017-01-03-02.1.gz

      This causes problems for the file's consumer, which attempts to process the partial file. I want to be able to distinguish between a partial gzipped file and a completed gzipped file. For example, I would like to setup a configuration that while the file is being gzipped, it is written with a different name e.g.: /usr/test/req.log.2017-01-03-02.1.gz.temp and once it is completely gzipped the name is changed to the final name /usr/test/req.log.2017-01-03-02.1.gz

      One way to achieve this is to add a new parameter like "temporaryCompressedFilePattern" as follows:

      <RollingRandomAccessFile name="RollingReqAppender"
              fileName="/usr/test/req.log"
              filePattern="/usr/test/req.log.%d{yyyy-MM-dd-HH}.%i.gz"
              temporaryCompressedFilePattern="/usr/test/req.log.%d{yyyy-MM-dd-HH}.%i.gz.temp"
      

      Another option is to make such behavior the default behavior without adding a new parameter.

      This was first discussed at http://stackoverflow.com/questions/41457492/partial-gz-file-written-by-log4j2
      Creating this feature request as suggested by @rpopma

        Issue Links

          Activity

          Hide
          phymbert Pierrick HYMBERT added a comment -

          Hello Gary Gregory, Ralph Goers,

          I have done a first implementation of this feature request, I suggest to introduce a new attribute at DefaultRolloverStrategy level.

          A configuration example looks like:

          <RollingFile name="RollingFile" fileName="${filename}"
                           filePattern="target/rolling2/test1-$${date:MM-dd-yyyy}-%i.log.gz"
                           createOnDemand="true">
                <PatternLayout>
                  <Pattern>%m%n</Pattern>
                </PatternLayout>
                <SizeBasedTriggeringPolicy size="500" />
                <DefaultRolloverStrategy
                	 fileIndex="nomax"
                	 compressTmpFilePattern="target/rolling-tmp/test1-$${date:MM-dd-yyyy}-%i.log.gz.tmp"/>
              </RollingFile>
          

          compressTmpFilePattern attribute will be use as temporary file name during compression.
          Appreciate your review.

          NB: mvn clean install success

          Show
          phymbert Pierrick HYMBERT added a comment - Hello Gary Gregory , Ralph Goers , I have done a first implementation of this feature request, I suggest to introduce a new attribute at DefaultRolloverStrategy level. A configuration example looks like: <RollingFile name= "RollingFile" fileName= "${filename}" filePattern= "target/rolling2/test1-$${date:MM-dd-yyyy}-%i.log.gz" createOnDemand= "true" > <PatternLayout> <Pattern> %m%n </Pattern> </PatternLayout> <SizeBasedTriggeringPolicy size= "500" /> <DefaultRolloverStrategy fileIndex= "nomax" compressTmpFilePattern= "target/rolling-tmp/test1-$${date:MM-dd-yyyy}-%i.log.gz.tmp" /> </RollingFile> compressTmpFilePattern attribute will be use as temporary file name during compression. Appreciate your review. NB: mvn clean install success
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user phymbert opened a pull request:

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

          LOG4J2-1766 Temporary archived file pattern during compression

          Rebased patch onto master, added documentation

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

          $ git pull https://github.com/phymbert/logging-log4j2 LOG4J2-1766

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

          https://github.com/apache/logging-log4j2/pull/86.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 #86


          commit af4d3ddd18babe29f3983f83631b36d987cd022c
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: 2017-06-23T11:49:43Z

          LOG4J2-1766 Rebase onto master from original jira patch.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit 33d3cf58b7c5da790170469e6e77e0680c49b934
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: 2017-06-23T11:50:24Z

          LOG4J2-1766 Documentation of compressTmpFilePattern
          DefaultRolloverStrategy parameter.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit e583d1ef653569fd97b57a5d156a370396e1116f
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: 2017-06-23T11:54:58Z

          LOG4J2-1766 Little formating.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user phymbert opened a pull request: https://github.com/apache/logging-log4j2/pull/86 LOG4J2-1766 Temporary archived file pattern during compression Rebased patch onto master, added documentation You can merge this pull request into a Git repository by running: $ git pull https://github.com/phymbert/logging-log4j2 LOG4J2-1766 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/logging-log4j2/pull/86.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 #86 commit af4d3ddd18babe29f3983f83631b36d987cd022c Author: phymbert <pierrick.hymbert@gmail.com> Date: 2017-06-23T11:49:43Z LOG4J2-1766 Rebase onto master from original jira patch. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit 33d3cf58b7c5da790170469e6e77e0680c49b934 Author: phymbert <pierrick.hymbert@gmail.com> Date: 2017-06-23T11:50:24Z LOG4J2-1766 Documentation of compressTmpFilePattern DefaultRolloverStrategy parameter. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit e583d1ef653569fd97b57a5d156a370396e1116f Author: phymbert <pierrick.hymbert@gmail.com> Date: 2017-06-23T11:54:58Z LOG4J2-1766 Little formating. Signed-off-by: phymbert <pierrick.hymbert@gmail.com>
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user phymbert commented on the issue:

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

          Hi @garydgregory, understood, little question, is it preferable to deprecate existing constructor and create another one or set after instantiate new parameter in the builder ?

          Show
          githubbot ASF GitHub Bot added a comment - Github user phymbert commented on the issue: https://github.com/apache/logging-log4j2/pull/86 Hi @garydgregory, understood, little question, is it preferable to deprecate existing constructor and create another one or set after instantiate new parameter in the builder ?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user phymbert commented on the issue:

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

          Added Builder API for rollover strategies, I introduce new constructors for this additional parameter. Please check.

          Show
          githubbot ASF GitHub Bot added a comment - Github user phymbert commented on the issue: https://github.com/apache/logging-log4j2/pull/86 Added Builder API for rollover strategies, I introduce new constructors for this additional parameter. Please check.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user phymbert closed the pull request at:

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

          Show
          githubbot ASF GitHub Bot added a comment - Github user phymbert closed the pull request at: https://github.com/apache/logging-log4j2/pull/86
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user phymbert opened a pull request:

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

          LOG4J2-1766 Temporary compress directory during rollover

          commit a135e42cbafcaee88a015af80e4f411d688934e5
          Merge: 5fe81f4 d66b640
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Mon Jun 26 10:48:52 2017 +0300

          Merge branch 'LOG4J2-1766' of github.com:phymbert/logging-log4j2 into LOG4J2-1766

          commit 5fe81f452741ccedadbab85e57982676b7d3f109
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 19:27:28 2017 +0300

          LOG4J2-1766 Fix javadoc, little switch min/max

          commit d74ff872bfb0824969d277fbbe5409918cc90840
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 14:23:24 2017 +0300

          LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and
          DirectWriteRolloverStrategy. Add test and documentation for
          DirectWriteRolloverStrategy
          and tmp compress directory.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit d267ff72b68e6a412931ff97baa2d9eb2dc29e8a
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:54:58 2017 +0300

          LOG4J2-1766 Little formating.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit 8a5f863e3860d2985113d0e9c61153dfad6a12c1
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:50:24 2017 +0300

          LOG4J2-1766 Documentation of compressTmpFilePattern
          DefaultRolloverStrategy parameter.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit cbc36b77d09309b832afa6236c2d44cf4a5bbe80
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:49:43 2017 +0300

          LOG4J2-1766 Rebase onto master from original jira patch.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit d66b640fb302d31618c3d253a89ba051b3067965
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 19:27:28 2017 +0300

          LOG4J2-1766 Fix javadoc, little switch min/max

          commit ba01986addcbc9d75f1b2a07319878e177a78a9f
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 14:23:24 2017 +0300

          LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and
          DirectWriteRolloverStrategy. Add test and documentation for
          DirectWriteRolloverStrategy
          and tmp compress directory.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit e583d1ef653569fd97b57a5d156a370396e1116f
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:54:58 2017 +0300

          LOG4J2-1766 Little formating.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit 33d3cf58b7c5da790170469e6e77e0680c49b934
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:50:24 2017 +0300

          LOG4J2-1766 Documentation of compressTmpFilePattern
          DefaultRolloverStrategy parameter.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit af4d3ddd18babe29f3983f83631b36d987cd022c
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:49:43 2017 +0300

          LOG4J2-1766 Rebase onto master from original jira patch.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

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

          $ git pull https://github.com/phymbert/logging-log4j2 LOG4J2-1766

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

          https://github.com/apache/logging-log4j2/pull/88.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 #88


          commit 576147961529c7cfdd23d76aa14dc3767e0671d8
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: 2017-06-26T07:54:40Z

          Squashed commit of the following:

          commit a135e42cbafcaee88a015af80e4f411d688934e5
          Merge: 5fe81f4 d66b640
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Mon Jun 26 10:48:52 2017 +0300

          Merge branch 'LOG4J2-1766' of github.com:phymbert/logging-log4j2 into LOG4J2-1766

          commit 5fe81f452741ccedadbab85e57982676b7d3f109
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 19:27:28 2017 +0300

          LOG4J2-1766 Fix javadoc, little switch min/max

          commit d74ff872bfb0824969d277fbbe5409918cc90840
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 14:23:24 2017 +0300

          LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and
          DirectWriteRolloverStrategy. Add test and documentation for
          DirectWriteRolloverStrategy
          and tmp compress directory.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit d267ff72b68e6a412931ff97baa2d9eb2dc29e8a
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:54:58 2017 +0300

          LOG4J2-1766 Little formating.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit 8a5f863e3860d2985113d0e9c61153dfad6a12c1
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:50:24 2017 +0300

          LOG4J2-1766 Documentation of compressTmpFilePattern
          DefaultRolloverStrategy parameter.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit cbc36b77d09309b832afa6236c2d44cf4a5bbe80
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:49:43 2017 +0300

          LOG4J2-1766 Rebase onto master from original jira patch.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit d66b640fb302d31618c3d253a89ba051b3067965
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 19:27:28 2017 +0300

          LOG4J2-1766 Fix javadoc, little switch min/max

          commit ba01986addcbc9d75f1b2a07319878e177a78a9f
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Sat Jun 24 14:23:24 2017 +0300

          LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and
          DirectWriteRolloverStrategy. Add test and documentation for
          DirectWriteRolloverStrategy
          and tmp compress directory.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit e583d1ef653569fd97b57a5d156a370396e1116f
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:54:58 2017 +0300

          LOG4J2-1766 Little formating.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit 33d3cf58b7c5da790170469e6e77e0680c49b934
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:50:24 2017 +0300

          LOG4J2-1766 Documentation of compressTmpFilePattern
          DefaultRolloverStrategy parameter.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>

          commit af4d3ddd18babe29f3983f83631b36d987cd022c
          Author: phymbert <pierrick.hymbert@gmail.com>
          Date: Fri Jun 23 14:49:43 2017 +0300

          LOG4J2-1766 Rebase onto master from original jira patch.

          Signed-off-by: phymbert <pierrick.hymbert@gmail.com>


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user phymbert opened a pull request: https://github.com/apache/logging-log4j2/pull/88 LOG4J2-1766 Temporary compress directory during rollover commit a135e42cbafcaee88a015af80e4f411d688934e5 Merge: 5fe81f4 d66b640 Author: phymbert <pierrick.hymbert@gmail.com> Date: Mon Jun 26 10:48:52 2017 +0300 Merge branch ' LOG4J2-1766 ' of github.com:phymbert/logging-log4j2 into LOG4J2-1766 commit 5fe81f452741ccedadbab85e57982676b7d3f109 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 19:27:28 2017 +0300 LOG4J2-1766 Fix javadoc, little switch min/max commit d74ff872bfb0824969d277fbbe5409918cc90840 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 14:23:24 2017 +0300 LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and DirectWriteRolloverStrategy. Add test and documentation for DirectWriteRolloverStrategy and tmp compress directory. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit d267ff72b68e6a412931ff97baa2d9eb2dc29e8a Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:54:58 2017 +0300 LOG4J2-1766 Little formating. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit 8a5f863e3860d2985113d0e9c61153dfad6a12c1 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:50:24 2017 +0300 LOG4J2-1766 Documentation of compressTmpFilePattern DefaultRolloverStrategy parameter. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit cbc36b77d09309b832afa6236c2d44cf4a5bbe80 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:49:43 2017 +0300 LOG4J2-1766 Rebase onto master from original jira patch. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit d66b640fb302d31618c3d253a89ba051b3067965 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 19:27:28 2017 +0300 LOG4J2-1766 Fix javadoc, little switch min/max commit ba01986addcbc9d75f1b2a07319878e177a78a9f Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 14:23:24 2017 +0300 LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and DirectWriteRolloverStrategy. Add test and documentation for DirectWriteRolloverStrategy and tmp compress directory. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit e583d1ef653569fd97b57a5d156a370396e1116f Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:54:58 2017 +0300 LOG4J2-1766 Little formating. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit 33d3cf58b7c5da790170469e6e77e0680c49b934 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:50:24 2017 +0300 LOG4J2-1766 Documentation of compressTmpFilePattern DefaultRolloverStrategy parameter. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit af4d3ddd18babe29f3983f83631b36d987cd022c Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:49:43 2017 +0300 LOG4J2-1766 Rebase onto master from original jira patch. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> You can merge this pull request into a Git repository by running: $ git pull https://github.com/phymbert/logging-log4j2 LOG4J2-1766 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/logging-log4j2/pull/88.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 #88 commit 576147961529c7cfdd23d76aa14dc3767e0671d8 Author: phymbert <pierrick.hymbert@gmail.com> Date: 2017-06-26T07:54:40Z Squashed commit of the following: commit a135e42cbafcaee88a015af80e4f411d688934e5 Merge: 5fe81f4 d66b640 Author: phymbert <pierrick.hymbert@gmail.com> Date: Mon Jun 26 10:48:52 2017 +0300 Merge branch ' LOG4J2-1766 ' of github.com:phymbert/logging-log4j2 into LOG4J2-1766 commit 5fe81f452741ccedadbab85e57982676b7d3f109 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 19:27:28 2017 +0300 LOG4J2-1766 Fix javadoc, little switch min/max commit d74ff872bfb0824969d277fbbe5409918cc90840 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 14:23:24 2017 +0300 LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and DirectWriteRolloverStrategy. Add test and documentation for DirectWriteRolloverStrategy and tmp compress directory. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit d267ff72b68e6a412931ff97baa2d9eb2dc29e8a Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:54:58 2017 +0300 LOG4J2-1766 Little formating. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit 8a5f863e3860d2985113d0e9c61153dfad6a12c1 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:50:24 2017 +0300 LOG4J2-1766 Documentation of compressTmpFilePattern DefaultRolloverStrategy parameter. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit cbc36b77d09309b832afa6236c2d44cf4a5bbe80 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:49:43 2017 +0300 LOG4J2-1766 Rebase onto master from original jira patch. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit d66b640fb302d31618c3d253a89ba051b3067965 Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 19:27:28 2017 +0300 LOG4J2-1766 Fix javadoc, little switch min/max commit ba01986addcbc9d75f1b2a07319878e177a78a9f Author: phymbert <pierrick.hymbert@gmail.com> Date: Sat Jun 24 14:23:24 2017 +0300 LOG4J2-1766 Introduce builder API in DefaultRolloverStrategy and DirectWriteRolloverStrategy. Add test and documentation for DirectWriteRolloverStrategy and tmp compress directory. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit e583d1ef653569fd97b57a5d156a370396e1116f Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:54:58 2017 +0300 LOG4J2-1766 Little formating. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit 33d3cf58b7c5da790170469e6e77e0680c49b934 Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:50:24 2017 +0300 LOG4J2-1766 Documentation of compressTmpFilePattern DefaultRolloverStrategy parameter. Signed-off-by: phymbert <pierrick.hymbert@gmail.com> commit af4d3ddd18babe29f3983f83631b36d987cd022c Author: phymbert <pierrick.hymbert@gmail.com> Date: Fri Jun 23 14:49:43 2017 +0300 LOG4J2-1766 Rebase onto master from original jira patch. Signed-off-by: phymbert <pierrick.hymbert@gmail.com>
          Hide
          phymbert Pierrick HYMBERT added a comment -

          Please consider this new new PR, I messed up while rebase onto master...

          Show
          phymbert Pierrick HYMBERT added a comment - Please consider this new new PR, I messed up while rebase onto master...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user jvz commented on the issue:

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

          Depends if the constructors are private or not. For public ones where having a default value for the new constructor doesn't make much sense, deprecation is the way to go. When a sensible default is possible, I wouldn't bother deprecating the old one.

          Show
          githubbot ASF GitHub Bot added a comment - Github user jvz commented on the issue: https://github.com/apache/logging-log4j2/pull/86 Depends if the constructors are private or not. For public ones where having a default value for the new constructor doesn't make much sense, deprecation is the way to go. When a sensible default is possible, I wouldn't bother deprecating the old one.
          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/88#discussion_r124051928

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java —
          @@ -94,8 +285,10 @@

          • @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs
          • @param config The Configuration.
          • @return A DefaultRolloverStrategy.
            + * @deprecated Since log4j-2.8.3 Usage of Builder API is preferable
              • End diff –

          The next release will be 2.9.0. We still have 2.8.3-SNAPSHOT in the POM files as a quirk of our development process. If you look at the changes.xml file, you will see "2.9.0" as the next release

          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/88#discussion_r124051928 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java — @@ -94,8 +285,10 @@ @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs @param config The Configuration. @return A DefaultRolloverStrategy. + * @deprecated Since log4j-2.8.3 Usage of Builder API is preferable End diff – The next release will be 2.9.0. We still have 2.8.3-SNAPSHOT in the POM files as a quirk of our development process. If you look at the changes.xml file, you will see "2.9.0" as the next release
          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/88#discussion_r124051596

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java —
          @@ -83,6 +85,195 @@
          private static final int DEFAULT_WINDOW_SIZE = 7;

          /**
          + * Builds DefaultRolloverStrategy instances.
          + */
          + public static class Builder implements org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> {
          + @PluginBuilderAttribute("max")
          + private String max;
          +
          + @PluginBuilderAttribute("min")
          + private String min;
          +
          + @PluginBuilderAttribute("fileIndex")
          + private String fileIndex;
          +
          + @PluginBuilderAttribute("compressionLevel")
          + private String compressionLevelStr;
          +
          + @PluginElement("Actions")
          + private Action[] customActions;
          +
          + @PluginBuilderAttribute(value = "stopCustomActionsOnError")
          + private boolean stopCustomActionsOnError = true;
          +
          + @PluginBuilderAttribute(value = "compressTmpFilePattern")
          + private String compressTmpFilePattern;
          +
          + @PluginConfiguration
          + private Configuration config;
          +
          + @Override
          + public DefaultRolloverStrategy build() {
          + int minIndex;
          + int maxIndex;
          + boolean useMax;
          +
          + if (fileIndex != null && fileIndex.equalsIgnoreCase("nomax"))

          { + minIndex = Integer.MIN_VALUE; + maxIndex = Integer.MAX_VALUE; + useMax = false; + }

          else {
          + useMax = fileIndex == null ? true : fileIndex.equalsIgnoreCase("max");
          + minIndex = MIN_WINDOW_SIZE;
          + if (min != null) {
          + minIndex = Integer.parseInt(min);
          + if (minIndex < 1)

          { + LOGGER.error("Minimum window size too small. Limited to " + MIN_WINDOW_SIZE); + minIndex = MIN_WINDOW_SIZE; + }

          + }
          + maxIndex = DEFAULT_WINDOW_SIZE;
          + if (max != null) {
          + maxIndex = Integer.parseInt(max);
          + if (maxIndex < minIndex)

          { + maxIndex = minIndex < DEFAULT_WINDOW_SIZE ? DEFAULT_WINDOW_SIZE : minIndex; + LOGGER.error("Maximum window size must be greater than the minimum windows size. Set to " + maxIndex); + }

          + }
          + }
          + final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION);
          + return new DefaultRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, config.getStrSubstitutor(),
          + customActions, stopCustomActionsOnError, compressTmpFilePattern);
          + }
          +
          + public String getMax()

          { + return max; + }

          +
          + /**
          + * Define the maximum number of files to keep.
          — End diff –

          Javadoc comments should use the active voice, IOW, "Defines..." instead of "Define...". So you can read it as "The method foo defines...".

          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/88#discussion_r124051596 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java — @@ -83,6 +85,195 @@ private static final int DEFAULT_WINDOW_SIZE = 7; /** + * Builds DefaultRolloverStrategy instances. + */ + public static class Builder implements org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> { + @PluginBuilderAttribute("max") + private String max; + + @PluginBuilderAttribute("min") + private String min; + + @PluginBuilderAttribute("fileIndex") + private String fileIndex; + + @PluginBuilderAttribute("compressionLevel") + private String compressionLevelStr; + + @PluginElement("Actions") + private Action[] customActions; + + @PluginBuilderAttribute(value = "stopCustomActionsOnError") + private boolean stopCustomActionsOnError = true; + + @PluginBuilderAttribute(value = "compressTmpFilePattern") + private String compressTmpFilePattern; + + @PluginConfiguration + private Configuration config; + + @Override + public DefaultRolloverStrategy build() { + int minIndex; + int maxIndex; + boolean useMax; + + if (fileIndex != null && fileIndex.equalsIgnoreCase("nomax")) { + minIndex = Integer.MIN_VALUE; + maxIndex = Integer.MAX_VALUE; + useMax = false; + } else { + useMax = fileIndex == null ? true : fileIndex.equalsIgnoreCase("max"); + minIndex = MIN_WINDOW_SIZE; + if (min != null) { + minIndex = Integer.parseInt(min); + if (minIndex < 1) { + LOGGER.error("Minimum window size too small. Limited to " + MIN_WINDOW_SIZE); + minIndex = MIN_WINDOW_SIZE; + } + } + maxIndex = DEFAULT_WINDOW_SIZE; + if (max != null) { + maxIndex = Integer.parseInt(max); + if (maxIndex < minIndex) { + maxIndex = minIndex < DEFAULT_WINDOW_SIZE ? DEFAULT_WINDOW_SIZE : minIndex; + LOGGER.error("Maximum window size must be greater than the minimum windows size. Set to " + maxIndex); + } + } + } + final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION); + return new DefaultRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, config.getStrSubstitutor(), + customActions, stopCustomActionsOnError, compressTmpFilePattern); + } + + public String getMax() { + return max; + } + + /** + * Define the maximum number of files to keep. — End diff – Javadoc comments should use the active voice, IOW, "Defines..." instead of "Define...". So you can read it as "The method foo defines...".
          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/88#discussion_r124051332

          — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java —
          @@ -83,6 +85,195 @@
          private static final int DEFAULT_WINDOW_SIZE = 7;

          /**
          + * Builds DefaultRolloverStrategy instances.
          + */
          + public static class Builder implements org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> {
          + @PluginBuilderAttribute("max")
          + private String max;
          +
          + @PluginBuilderAttribute("min")
          + private String min;
          +
          + @PluginBuilderAttribute("fileIndex")
          + private String fileIndex;
          +
          + @PluginBuilderAttribute("compressionLevel")
          + private String compressionLevelStr;
          +
          + @PluginElement("Actions")
          + private Action[] customActions;
          +
          + @PluginBuilderAttribute(value = "stopCustomActionsOnError")
          + private boolean stopCustomActionsOnError = true;
          +
          + @PluginBuilderAttribute(value = "compressTmpFilePattern")
          — End diff –

          I like the original name from the ticket better: "temporaryCompressedFilePattern". I do not think we use "tmp" much if at all. IMO, if we want short "temp" would be friendlier: "tempCompressedFilePattern",

          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/88#discussion_r124051332 — Diff: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java — @@ -83,6 +85,195 @@ private static final int DEFAULT_WINDOW_SIZE = 7; /** + * Builds DefaultRolloverStrategy instances. + */ + public static class Builder implements org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> { + @PluginBuilderAttribute("max") + private String max; + + @PluginBuilderAttribute("min") + private String min; + + @PluginBuilderAttribute("fileIndex") + private String fileIndex; + + @PluginBuilderAttribute("compressionLevel") + private String compressionLevelStr; + + @PluginElement("Actions") + private Action[] customActions; + + @PluginBuilderAttribute(value = "stopCustomActionsOnError") + private boolean stopCustomActionsOnError = true; + + @PluginBuilderAttribute(value = "compressTmpFilePattern") — End diff – I like the original name from the ticket better: "temporaryCompressedFilePattern". I do not think we use "tmp" much if at all. IMO, if we want short "temp" would be friendlier: "tempCompressedFilePattern",
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit e7b638929cc71ed626b52263ac6a04388b1e7dbd in logging-log4j2's branch refs/heads/master from Pierrick HYMBERT
          [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=e7b6389 ]

          LOG4J2-1766 Temporary compress directory during rollover (#88).

          Show
          jira-bot ASF subversion and git services added a comment - Commit e7b638929cc71ed626b52263ac6a04388b1e7dbd in logging-log4j2's branch refs/heads/master from Pierrick HYMBERT [ https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;h=e7b6389 ] LOG4J2-1766 Temporary compress directory during rollover (#88).
          Hide
          garydgregory Gary Gregory added a comment -

          Partial patch applied followed up by a few tweaks.

          I did not apply the test classes Tmp since they seemed to be early versions of the current Temp test classes.

          Pierrick HYMBERT: please confirm, verify and close.

          Thank you and keep'em coming!

          Gary

          Show
          garydgregory Gary Gregory added a comment - Partial patch applied followed up by a few tweaks. I did not apply the test classes Tmp since they seemed to be early versions of the current Temp test classes. Pierrick HYMBERT : please confirm, verify and close. Thank you and keep'em coming! Gary
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user phymbert commented on the issue:

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

          Thank you, it is ok, closed.

          Show
          githubbot ASF GitHub Bot added a comment - Github user phymbert commented on the issue: https://github.com/apache/logging-log4j2/pull/88 Thank you, it is ok, closed.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user phymbert closed the pull request at:

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

          Show
          githubbot ASF GitHub Bot added a comment - Github user phymbert closed the pull request at: https://github.com/apache/logging-log4j2/pull/88
          Hide
          phymbert Pierrick HYMBERT added a comment -

          Hello, it is perfect for me, thank you for your support!
          Sameer Pradhan Please check and close, expected in next release 2.9

          Show
          phymbert Pierrick HYMBERT added a comment - Hello, it is perfect for me, thank you for your support! Sameer Pradhan Please check and close, expected in next release 2.9

            People

            • Assignee:
              Unassigned
              Reporter:
              spradhan Sameer Pradhan
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development