You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Pierrick HYMBERT (JIRA)" <ji...@apache.org> on 2017/06/20 11:06:00 UTC

[jira] [Updated] (LOG4J2-1766) Distinguish between partial and completed .gz archive file

     [ https://issues.apache.org/jira/browse/LOG4J2-1766?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pierrick HYMBERT updated LOG4J2-1766:
-------------------------------------
    Attachment: LOG4J2-1766.patch

Hello [~garydgregory], [~ralph.goers@dslextreme.com],

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:
{code:xml}
<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>
{code}

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

NB: mvn clean install success

> Distinguish between partial and completed .gz archive file
> ----------------------------------------------------------
>
>                 Key: LOG4J2-1766
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1766
>             Project: Log4j 2
>          Issue Type: New Feature
>    Affects Versions: 2.5
>            Reporter: Sameer Pradhan
>              Labels: features
>         Attachments: LOG4J2-1766.patch
>
>
> 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



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)