[ 
https://issues.apache.org/jira/browse/LOG4J2-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16969848#comment-16969848
 ] 

Ralph Goers commented on LOG4J2-2712:
-------------------------------------

I have been able to duplicate the problem and I can see that there are two 
things that have to occur to cause this problem:
 # The filename has to match the file pattern.
 # The min value has to be set to 1.

What happens here is that the call to getEligibleFiles returns the list of 
files that are to be evaluated in the rollover. Because the file name matches 
the file pattern it is included in the list. In my tests if min="1" was not 
specified then the compression still happened but the outcome was still not 
good as the file containing the current logs gets deleted. With min="1" set it 
looks like it doesn't compress the files and it renames the file it is logging 
to.  Hopefully excluding the target filename from the eligible files list 
should correct the problem.

> log4j2 can't compress rollover log file
> ---------------------------------------
>
>                 Key: LOG4J2-2712
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2712
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Pattern Converters
>    Affects Versions: 2.11.0
>            Reporter: Frank Fan
>            Priority: Major
>         Attachments: log_error1.log, logwrong.txt
>
>
> Hi, 
>   When I used log4j2, I found in below case log4j2 can't compress my  rotate 
> log file.
> <RollingRandomAccessFile name="mf-info" 
> fileName="/var/log/oss_activity0_0.log"
>  filePattern="/var/log/oss_activity0_%i.log.gz">
> ...
> <Policies>
>     <TimeBasedRollingPolicy/>
>     <SizeBasedTriggeringPolicy size="50 MB"/>
>  </Policies>
>  <DefaultRolloverStrategy max="50" min="1" fileIndex="min">
> </DefaultRolloverStrategy>
> </RollingRandomAccessFile>
>  
> I found when log file will rename to oss_activity0_1.log when 
> oss_activity0_0.log reach 50MB size, but it will not be compressed to 
> oss_activity0_1.log.gz. 
>  
> Could you please help check this issue?
>  
> Thanks
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to