On rollover, gzip and keep unzipped file

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

On rollover, gzip and keep unzipped file

Sameer Pradhan
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




Reply | Threaded
Open this post in threaded view
|

Re: On rollover, gzip and keep unzipped file

Sameer Pradhan
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" <[hidden email]> 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










Reply | Threaded
Open this post in threaded view
|

Re: On rollover, gzip and keep unzipped file

Matt Sicker
Sounds like a new feature most likely, though I'm not super in-depth in the
rollover/cron feature list.

On Thu, 24 Jan 2019 at 01:36, Sameer Pradhan <[hidden email]> wrote:

> 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" <[hidden email]> 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
>
>
>
>
>
>
>
>
>
>
>

--
Matt Sicker <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: On rollover, gzip and keep unzipped file

Ralph Goers
In reply to this post by Sameer Pradhan
Can you explain the use case for why you would want both?  The primary reason for gzipping the files is to save space. Having both causes more space to be used.

Ralph

> On Jan 24, 2019, at 12:35 AM, Sameer Pradhan <[hidden email]> wrote:
>
> 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" <[hidden email]> 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
>
>
>
>
>
>
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]