You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Greg Thomas <gr...@gmail.com> on 2016/12/08 14:07:45 UTC

Zipped rolling file - name of file entry

I'm using a RollingFileAppender, configured similar to ...

<Appenders>
    <RollingFile name="rf" fileName="../logs/my.log"
filePattern="../logs/my.%i.log.zip">
        <PatternLayout>
            <pattern>%d %-5p [%c{1}] %X - %m%n</pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="100 MB"/>
        </Policies>
        <DefaultRolloverStrategy max="20"/>
    </RollingFile>
</Appenders>


So far so good. I get 20 logs files, my.1.log.zip -> my.20.log.zip, as I
would expect.

However, the file contained with "my.20.log.zip" is called ...
"my.1.log.zip". In fact, every log file contains a file of the same name,
"my.1.log.zip".

Whilst I can see why this would be the case, it still breaks the principle
of least surprise in my mind. Is there a configuration option I can use to
avoid this - or any other mechanism I missed that would use a more natural
file naming mechanism?

Thanks,

Greg

Re: Zipped rolling file - name of file entry

Posted by Greg Thomas <gr...@gmail.com>.
> How important is this as a feature/fix? Could you use gzip instead?

Our support guys explicitly requested zip over gzip as it makes it easier
to handle on locked down Windows machines.

We've now worked around it by writing a Powershell script that bulk unzips
the files and renames the entries as it goes, so it's not vital, just
something odd that I spotted.

Greg

On 9 December 2016 at 16:21, Christopher Schultz <
chris@christopherschultz.net> wrote:

> Greg,
>
> On 12/9/16 3:46 AM, Greg Thomas wrote:
> >> So, to clarify, the file contained in the rolled over zip files (like
> > "my.20.log.zip") is called "my.1.log"
> >
> > Correct. An error in composing my original email, apologies.
>
> The problem is that this kind of thing was (likely) designed around
> gzipping a file, which contains no structure. Adding ZIP support added a
> dimension that didn't previously exist: file structure within the archive.
>
> Re-naming a filename within a ZIP file isn't as straightforward as you
> might expect[1].
>
> How important is this as a feature/fix? Could you use gzip instead?
>
> -chris
>
>
> [1] http://stackoverflow.com/a/848053/276232
>
> > On 8 December 2016 at 23:52, Remko Popma <re...@gmail.com> wrote:
> >
> >> Greg,
> >>
> >> So, to clarify, the file contained in the rolled over zip files (like
> >> "my.20.log.zip") is called "my.1.log", not "my.1.log.zip", correct?
> >> (Your original email said the rolled over zip files contain zip files,
> >> which sounds like a bug...)
> >>
> >> Sent from my iPhone
> >>
> >>> On 9 Dec 2016, at 2:35, Greg Thomas <gr...@gmail.com> wrote:
> >>>
> >>>> On 8 December 2016 at 15:58, Apache <ra...@dslextreme.com>
> wrote:
> >>>>
> >>>> That indeed does seem strange. I will have to try it myself. You may
> >> have
> >>>> found a bug.
> >>>
> >>>
> >>> Thinking on this a bit more ...
> >>>
> >>> At a point in time, my.1.log is zipped to my.1.log.zip
> >>>
> >>> Some time later, my.1.log.zip is renamed to my.2.log.zip - in terms of
> >>> effort, it's possible to either
> >>>
> >>> a) Leave the contents of the ZIP file unchanged. so my.2.log.zip (and
> >>> my.XXX.log.zip) all contain my.1.log - what currently happens
> >>>
> >>> b) When my.1.log.zip is renamed to my.2.log.zip, recognise that it only
> >>> contains one file, and rename the contained file from my.1.log to
> >> my.2.log
> >>> (is it possible to rename a file contained in a ZIP without re-creating
> >> it?
> >>> What about gzip files, etc. etc.?)
> >>>
> >>> c) When it's necessary to rename my.1.log.zip to my.2.log.zip,
> recognise
> >>> that it only contains one file, extract my.1.log, rename it to
> my.2.log,
> >>> and then zip it up into my.2.log.zip.
> >>>
> >>> Greg
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
> >
>
>

Re: Zipped rolling file - name of file entry

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Greg,

On 12/9/16 3:46 AM, Greg Thomas wrote:
>> So, to clarify, the file contained in the rolled over zip files (like
> "my.20.log.zip") is called "my.1.log"
> 
> Correct. An error in composing my original email, apologies.

The problem is that this kind of thing was (likely) designed around
gzipping a file, which contains no structure. Adding ZIP support added a
dimension that didn't previously exist: file structure within the archive.

Re-naming a filename within a ZIP file isn't as straightforward as you
might expect[1].

How important is this as a feature/fix? Could you use gzip instead?

-chris


[1] http://stackoverflow.com/a/848053/276232

> On 8 December 2016 at 23:52, Remko Popma <re...@gmail.com> wrote:
> 
>> Greg,
>>
>> So, to clarify, the file contained in the rolled over zip files (like
>> "my.20.log.zip") is called "my.1.log", not "my.1.log.zip", correct?
>> (Your original email said the rolled over zip files contain zip files,
>> which sounds like a bug...)
>>
>> Sent from my iPhone
>>
>>> On 9 Dec 2016, at 2:35, Greg Thomas <gr...@gmail.com> wrote:
>>>
>>>> On 8 December 2016 at 15:58, Apache <ra...@dslextreme.com> wrote:
>>>>
>>>> That indeed does seem strange. I will have to try it myself. You may
>> have
>>>> found a bug.
>>>
>>>
>>> Thinking on this a bit more ...
>>>
>>> At a point in time, my.1.log is zipped to my.1.log.zip
>>>
>>> Some time later, my.1.log.zip is renamed to my.2.log.zip - in terms of
>>> effort, it's possible to either
>>>
>>> a) Leave the contents of the ZIP file unchanged. so my.2.log.zip (and
>>> my.XXX.log.zip) all contain my.1.log - what currently happens
>>>
>>> b) When my.1.log.zip is renamed to my.2.log.zip, recognise that it only
>>> contains one file, and rename the contained file from my.1.log to
>> my.2.log
>>> (is it possible to rename a file contained in a ZIP without re-creating
>> it?
>>> What about gzip files, etc. etc.?)
>>>
>>> c) When it's necessary to rename my.1.log.zip to my.2.log.zip, recognise
>>> that it only contains one file, extract my.1.log, rename it to my.2.log,
>>> and then zip it up into my.2.log.zip.
>>>
>>> Greg
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
> 


Re: Zipped rolling file - name of file entry

Posted by Greg Thomas <gr...@gmail.com>.
> So, to clarify, the file contained in the rolled over zip files (like
"my.20.log.zip") is called "my.1.log"

Correct. An error in composing my original email, apologies.

Greg

On 8 December 2016 at 23:52, Remko Popma <re...@gmail.com> wrote:

> Greg,
>
> So, to clarify, the file contained in the rolled over zip files (like
> "my.20.log.zip") is called "my.1.log", not "my.1.log.zip", correct?
> (Your original email said the rolled over zip files contain zip files,
> which sounds like a bug...)
>
> Sent from my iPhone
>
> > On 9 Dec 2016, at 2:35, Greg Thomas <gr...@gmail.com> wrote:
> >
> >> On 8 December 2016 at 15:58, Apache <ra...@dslextreme.com> wrote:
> >>
> >> That indeed does seem strange. I will have to try it myself. You may
> have
> >> found a bug.
> >
> >
> > Thinking on this a bit more ...
> >
> > At a point in time, my.1.log is zipped to my.1.log.zip
> >
> > Some time later, my.1.log.zip is renamed to my.2.log.zip - in terms of
> > effort, it's possible to either
> >
> > a) Leave the contents of the ZIP file unchanged. so my.2.log.zip (and
> > my.XXX.log.zip) all contain my.1.log - what currently happens
> >
> > b) When my.1.log.zip is renamed to my.2.log.zip, recognise that it only
> > contains one file, and rename the contained file from my.1.log to
> my.2.log
> > (is it possible to rename a file contained in a ZIP without re-creating
> it?
> > What about gzip files, etc. etc.?)
> >
> > c) When it's necessary to rename my.1.log.zip to my.2.log.zip, recognise
> > that it only contains one file, extract my.1.log, rename it to my.2.log,
> > and then zip it up into my.2.log.zip.
> >
> > Greg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Zipped rolling file - name of file entry

Posted by Remko Popma <re...@gmail.com>.
Greg,

So, to clarify, the file contained in the rolled over zip files (like "my.20.log.zip") is called "my.1.log", not "my.1.log.zip", correct?
(Your original email said the rolled over zip files contain zip files, which sounds like a bug...)

Sent from my iPhone

> On 9 Dec 2016, at 2:35, Greg Thomas <gr...@gmail.com> wrote:
> 
>> On 8 December 2016 at 15:58, Apache <ra...@dslextreme.com> wrote:
>> 
>> That indeed does seem strange. I will have to try it myself. You may have
>> found a bug.
> 
> 
> Thinking on this a bit more ...
> 
> At a point in time, my.1.log is zipped to my.1.log.zip
> 
> Some time later, my.1.log.zip is renamed to my.2.log.zip - in terms of
> effort, it's possible to either
> 
> a) Leave the contents of the ZIP file unchanged. so my.2.log.zip (and
> my.XXX.log.zip) all contain my.1.log - what currently happens
> 
> b) When my.1.log.zip is renamed to my.2.log.zip, recognise that it only
> contains one file, and rename the contained file from my.1.log to my.2.log
> (is it possible to rename a file contained in a ZIP without re-creating it?
> What about gzip files, etc. etc.?)
> 
> c) When it's necessary to rename my.1.log.zip to my.2.log.zip, recognise
> that it only contains one file, extract my.1.log, rename it to my.2.log,
> and then zip it up into my.2.log.zip.
> 
> Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Zipped rolling file - name of file entry

Posted by Greg Thomas <gr...@gmail.com>.
On 8 December 2016 at 15:58, Apache <ra...@dslextreme.com> wrote:

> That indeed does seem strange. I will have to try it myself. You may have
> found a bug.


Thinking on this a bit more ...

At a point in time, my.1.log is zipped to my.1.log.zip

Some time later, my.1.log.zip is renamed to my.2.log.zip - in terms of
effort, it's possible to either

a) Leave the contents of the ZIP file unchanged. so my.2.log.zip (and
my.XXX.log.zip) all contain my.1.log - what currently happens

b) When my.1.log.zip is renamed to my.2.log.zip, recognise that it only
contains one file, and rename the contained file from my.1.log to my.2.log
(is it possible to rename a file contained in a ZIP without re-creating it?
What about gzip files, etc. etc.?)

c) When it's necessary to rename my.1.log.zip to my.2.log.zip, recognise
that it only contains one file, extract my.1.log, rename it to my.2.log,
and then zip it up into my.2.log.zip.

Greg

Re: Zipped rolling file - name of file entry

Posted by Apache <ra...@dslextreme.com>.
That indeed does seem strange. I will have to try it myself. You may have found a bug.

Ralph

> On Dec 8, 2016, at 7:07 AM, Greg Thomas <gr...@gmail.com> wrote:
> 
> I'm using a RollingFileAppender, configured similar to ...
> 
> <Appenders>
>    <RollingFile name="rf" fileName="../logs/my.log"
> filePattern="../logs/my.%i.log.zip">
>        <PatternLayout>
>            <pattern>%d %-5p [%c{1}] %X - %m%n</pattern>
>        </PatternLayout>
>        <Policies>
>            <SizeBasedTriggeringPolicy size="100 MB"/>
>        </Policies>
>        <DefaultRolloverStrategy max="20"/>
>    </RollingFile>
> </Appenders>
> 
> 
> So far so good. I get 20 logs files, my.1.log.zip -> my.20.log.zip, as I
> would expect.
> 
> However, the file contained with "my.20.log.zip" is called ...
> "my.1.log.zip". In fact, every log file contains a file of the same name,
> "my.1.log.zip".
> 
> Whilst I can see why this would be the case, it still breaks the principle
> of least surprise in my mind. Is there a configuration option I can use to
> avoid this - or any other mechanism I missed that would use a more natural
> file naming mechanism?
> 
> Thanks,
> 
> Greg



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org