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 Ralph Goers <ra...@dslextreme.com> on 2019/02/02 06:59:46 UTC

Re: combine log4j2 SizeBasedTriggeringPolicy with CronTriggeringPolicy

Thanks for the report. I tested your sample project and the file pattern does not contain a ā€œ%Iā€. Without this files will get overwritten. But in the course of testing this after adding the %I I discovered that rolling was creating files with the wrong name. I have fixed that. Please try the latest on the release-2.x branch.

Ralph

> On Jan 29, 2019, at 3:42 AM, Franz van Betteraey <fv...@web.de> wrote:
> 
> I provided a running example project.
> https://github.com/FrVaBe/logging
> 
> Just run the Main class and monitor the files that are generated in target/logs.
> In the setup of this project they roll over every 30 seconds although they should already rotate when the size of 100KB is reached (which will not last 30 seconds on my computer).
>  
>  
>  
> 
> Gesendet: Dienstag, 29. Januar 2019 um 09:45 Uhr
> Von: "Franz van Betteraey" <fv...@web.de>
> An: log4j-user@logging.apache.org
> Betreff: combine log4j2 SizeBasedTriggeringPolicy with CronTriggeringPolicy
> Hi all,
>  
> I try to combine a log4j2 SizeBasedTriggeringPolicy with a CronTriggeringPolicy to roll over a file either at midnight or every 20MB (every minute or every 100KB for testing) like this:
>  
> <RollingFile name="RollingFile"
>     filePattern="target/logs/foobar-%d{yyyyMMdd-HHmmss}{UTC}.log">
>     <Layout type="PatternLayout" pattern="%date{DEFAULT} | %message%n" />
>     <Policies>
>         <SizeBasedTriggeringPolicy size="100KB" />
>         <CronTriggeringPolicy schedule="0 * * * * ? *" evaluateOnStartup="true" />
>     </Policies>
> </RollingFile>
>  
> Unfortunately only the CronTriggeringPolicy seems to work in this combination. No roll over is done when the file size limit is reached. Removing the 'CronTriggeringPolicy ' from the configuration will let the roll over happen every 100KB as expected.
>  
> Beware of the fact that I can not use the TimeBasedTriggeringPolicy because I need to have a second accurate date in the file name pattern but I want to roll over just every day (or every minute for testing here).
> Is this (unabalibility of combining CronTriggeringPolicy with other policies) a know bug or limitation when using the CronTriggeringPolicy?
>  
> I also asked this question on SO but without response so far:
> https://stackoverflow.com/q/54406364/367285
>  
> Any help would be appriciated.
>  
> Thanks ab best regards,
>   Franz
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 



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