logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sameer Pradhan <sprad...@4info.com>
Subject Re: On rollover, gzip and keep unzipped file
Date Thu, 24 Jan 2019 07:35:49 GMT
I am currently using



<RollingRandomAccessFile name="RollingRequestAppender"

    fileName="/mypath/log/requests.log"

    filePattern="/mypath/log/requests.log.%d{yyyy-MM-dd-HH-mm}.gz"

    immediateFlush="false" append="true">

    <DefaultRolloverStrategy

        fileIndex="nomax"

    tempCompressedFilePattern="/mypath/log/requests.log.%d{yyyy-MM-dd-HH-mm}.gz.tmp"/>

    <PatternLayout>

        <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS Z}%m%n</Pattern>

    </PatternLayout>

    <Policies>

        <TimeBasedTriggeringPolicy interval="1" modulate="true" />

    </Policies>

</RollingRandomAccessFile>



This produces the compressed rolled over file.

Removing .gz from the file pattern produces the uncompressed file.

    filePattern="/mypath/log/requests.log.%d{yyyy-MM-dd-HH-mm}.gz"



The idea is to have both created by log4j



Thanks.

-Sameer



On 1/23/19, 6:11 PM, "Sameer Pradhan" <spradhan@4info.com> wrote:



    When log4j rolls over a file and the filePattern ends with a compressed file suffic like
.gz, log4j compresses the rolled over file, which is quite useful.



    What I need is to have a uncompressed as well as a compressed rolled over file. Yeah,
that sounds a lot like having my cake and eating it too 😊



    How can I achieve this? This would be the log4j equivalent of gzip -k <filename>
which keeps the original file.

    I want to avoid rolling over to a gzipped file, and then uncompressing it myself.

    Or rolling over to uncompressed file and compressing it myself.

    Rather, need both files to be created by log4j



    Appreciate any suggestions.



    Thanks,

    -Sameer Pradhan










Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message