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 Arkin Yetis <ar...@gmail.com> on 2013/10/15 03:07:31 UTC

Re: roll over strategy question

Hi,
I can't seem to get the DefaultRolloverStrategy to work with the following
configuration. Is there anything I am doing wrong?
Thanks,
Arkin

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration status="info" name="ABC" >
      <appenders>
        <RollingFile name="localFile" fileName="test.log"
filePattern="test-%d{MM-dd-yyyy}.log.gz">
          <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
%M - %msg%n" />
          <TimeBasedTriggeringPolicy />
          <DefaultRolloverStrategy max="2" />
        </RollingFile>
      </appenders>

      <loggers>
        <root level="info">
          <appender-ref ref="localFile" />
        </root>
      </loggers>
    </configuration>

Re: roll over strategy question

Posted by Arkin Yetis <ar...@gmail.com>.
I looked into this and it seems that if a count is used to determine the
file to be deleted, some of the information needed (interval, modulate) is
in the TimeBasedTriggeringPolicy and the DefaultRolloverStrategy does not
have that information.

Would it be a good idea to introduce the concept of a
Cleanup/RetentionStrategy that gets executed by the RollingFileManager
after the rollover asynchronously?
Another option could be to not make it count based, but make it
timestamp/period based (such as retain all files matching the pattern with
last modified date or date pattern string less than x
weeks/days/months/etc  in the past).

Other options I considered using existing classes:
1. Adding TriggeringPolicy to the parameters of the rollover method in the
RolloverStrategy interface.
2. A new RolloverStrategy that is initialized with the policies.
3. DefaultRolloverStrategy rollover implementation uses the
RollingFileManager, which has access to the triggering policies, to
calculate past file name(s).
None of these seem ideal to me due to increased coupling.

All of this seems less straightforward than I thought it should be, can
anyone think of a simple solution or an idea that could lead to one?

- Arkin



On Sat, Oct 19, 2013 at 9:52 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> OK - feel free to submit a patch!
>
> Ralph
>
> On Oct 19, 2013, at 8:47 PM, Arkin Yetis <ar...@gmail.com> wrote:
>
> > Thanks, opened https://issues.apache.org/jira/browse/LOG4J2-435.
> >
> > Arkin
> >
> >
> > On Tue, Oct 15, 2013 at 8:34 AM, Ralph Goers <ralph.goers@dslextreme.com
> >wrote:
> >
> >> Not currently.  You should create a Jira to request it.  I suppose the
> max
> >> attribute could be used to limit the number of days if no %i is present,
> >> but if it is then it would only apply to that so it really wouldn't
> limit
> >> the total number of files.  So I am thinking a second attribute might
> be a
> >> better choice.
> >>
> >> Ralph
> >>
> >>
> >> On Oct 15, 2013, at 6:58 AM, Arkin Yetis <ar...@gmail.com> wrote:
> >>
> >>> Got it. It is rolling. I thought it would limit across days, too. Is
> >> there
> >>> a way to do cleanup across days currently?
> >>>
> >>> Thank you.
> >>>
> >>> - Arkin
> >>>
> >>> On Tuesday, October 15, 2013, Ralph Goers wrote:
> >>>
> >>>> What behavior are you seeing?  Is it never rolling or something else?
> >>>>
> >>>> The max attribute only applies if you have a %i in the file pattern.
> It
> >>>> would limit to 2 files per day if you had one in the patten, but not 2
> >>>> files across days.
> >>>>
> >>>> Ralph
> >>>>
> >>>>> On Oct 14, 2013, at 6:07 PM, Arkin Yetis <arkinyetis@gmail.com
> >> <javascript:;>>
> >>>> wrote:
> >>>>>
> >>>>> Hi,
> >>>>> I can't seem to get the DefaultRolloverStrategy to work with the
> >>>> following
> >>>>> configuration. Is there anything I am doing wrong?
> >>>>> Thanks,
> >>>>> Arkin
> >>>>>
> >>>>>  <?xml version="1.0" encoding="UTF-8"?>
> >>>>>  <configuration status="info" name="ABC" >
> >>>>>    <appenders>
> >>>>>      <RollingFile name="localFile" fileName="test.log"
> >>>>> filePattern="test-%d{MM-dd-yyyy}.log.gz">
> >>>>>        <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level
> %class{36}:%L
> >>>>> %M - %msg%n" />
> >>>>>        <TimeBasedTriggeringPolicy />
> >>>>>        <DefaultRolloverStrategy max="2" />
> >>>>>      </RollingFile>
> >>>>>    </appenders>
> >>>>>
> >>>>>    <loggers>
> >>>>>      <root level="info">
> >>>>>        <appender-ref ref="localFile" />
> >>>>>      </root>
> >>>>>    </loggers>
> >>>>>  </configuration>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> <javascript:;>
> >>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >> <javascript:;>
> >>>>
> >>>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>

Re: roll over strategy question

Posted by Ralph Goers <ra...@dslextreme.com>.
OK - feel free to submit a patch!

Ralph

On Oct 19, 2013, at 8:47 PM, Arkin Yetis <ar...@gmail.com> wrote:

> Thanks, opened https://issues.apache.org/jira/browse/LOG4J2-435.
> 
> Arkin
> 
> 
> On Tue, Oct 15, 2013 at 8:34 AM, Ralph Goers <ra...@dslextreme.com>wrote:
> 
>> Not currently.  You should create a Jira to request it.  I suppose the max
>> attribute could be used to limit the number of days if no %i is present,
>> but if it is then it would only apply to that so it really wouldn't limit
>> the total number of files.  So I am thinking a second attribute might be a
>> better choice.
>> 
>> Ralph
>> 
>> 
>> On Oct 15, 2013, at 6:58 AM, Arkin Yetis <ar...@gmail.com> wrote:
>> 
>>> Got it. It is rolling. I thought it would limit across days, too. Is
>> there
>>> a way to do cleanup across days currently?
>>> 
>>> Thank you.
>>> 
>>> - Arkin
>>> 
>>> On Tuesday, October 15, 2013, Ralph Goers wrote:
>>> 
>>>> What behavior are you seeing?  Is it never rolling or something else?
>>>> 
>>>> The max attribute only applies if you have a %i in the file pattern. It
>>>> would limit to 2 files per day if you had one in the patten, but not 2
>>>> files across days.
>>>> 
>>>> Ralph
>>>> 
>>>>> On Oct 14, 2013, at 6:07 PM, Arkin Yetis <arkinyetis@gmail.com
>> <javascript:;>>
>>>> wrote:
>>>>> 
>>>>> Hi,
>>>>> I can't seem to get the DefaultRolloverStrategy to work with the
>>>> following
>>>>> configuration. Is there anything I am doing wrong?
>>>>> Thanks,
>>>>> Arkin
>>>>> 
>>>>>  <?xml version="1.0" encoding="UTF-8"?>
>>>>>  <configuration status="info" name="ABC" >
>>>>>    <appenders>
>>>>>      <RollingFile name="localFile" fileName="test.log"
>>>>> filePattern="test-%d{MM-dd-yyyy}.log.gz">
>>>>>        <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
>>>>> %M - %msg%n" />
>>>>>        <TimeBasedTriggeringPolicy />
>>>>>        <DefaultRolloverStrategy max="2" />
>>>>>      </RollingFile>
>>>>>    </appenders>
>>>>> 
>>>>>    <loggers>
>>>>>      <root level="info">
>>>>>        <appender-ref ref="localFile" />
>>>>>      </root>
>>>>>    </loggers>
>>>>>  </configuration>
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> <javascript:;>
>>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> <javascript:;>
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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


Re: roll over strategy question

Posted by Arkin Yetis <ar...@gmail.com>.
Thanks, opened https://issues.apache.org/jira/browse/LOG4J2-435.

Arkin


On Tue, Oct 15, 2013 at 8:34 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> Not currently.  You should create a Jira to request it.  I suppose the max
> attribute could be used to limit the number of days if no %i is present,
> but if it is then it would only apply to that so it really wouldn't limit
> the total number of files.  So I am thinking a second attribute might be a
> better choice.
>
> Ralph
>
>
> On Oct 15, 2013, at 6:58 AM, Arkin Yetis <ar...@gmail.com> wrote:
>
> > Got it. It is rolling. I thought it would limit across days, too. Is
> there
> > a way to do cleanup across days currently?
> >
> > Thank you.
> >
> > - Arkin
> >
> > On Tuesday, October 15, 2013, Ralph Goers wrote:
> >
> >> What behavior are you seeing?  Is it never rolling or something else?
> >>
> >> The max attribute only applies if you have a %i in the file pattern. It
> >> would limit to 2 files per day if you had one in the patten, but not 2
> >> files across days.
> >>
> >> Ralph
> >>
> >>> On Oct 14, 2013, at 6:07 PM, Arkin Yetis <arkinyetis@gmail.com
> <javascript:;>>
> >> wrote:
> >>>
> >>> Hi,
> >>> I can't seem to get the DefaultRolloverStrategy to work with the
> >> following
> >>> configuration. Is there anything I am doing wrong?
> >>> Thanks,
> >>> Arkin
> >>>
> >>>   <?xml version="1.0" encoding="UTF-8"?>
> >>>   <configuration status="info" name="ABC" >
> >>>     <appenders>
> >>>       <RollingFile name="localFile" fileName="test.log"
> >>> filePattern="test-%d{MM-dd-yyyy}.log.gz">
> >>>         <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
> >>> %M - %msg%n" />
> >>>         <TimeBasedTriggeringPolicy />
> >>>         <DefaultRolloverStrategy max="2" />
> >>>       </RollingFile>
> >>>     </appenders>
> >>>
> >>>     <loggers>
> >>>       <root level="info">
> >>>         <appender-ref ref="localFile" />
> >>>       </root>
> >>>     </loggers>
> >>>   </configuration>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> <javascript:;>
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> <javascript:;>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: roll over strategy question

Posted by Ralph Goers <ra...@dslextreme.com>.
Not currently.  You should create a Jira to request it.  I suppose the max attribute could be used to limit the number of days if no %i is present, but if it is then it would only apply to that so it really wouldn't limit the total number of files.  So I am thinking a second attribute might be a better choice.

Ralph


On Oct 15, 2013, at 6:58 AM, Arkin Yetis <ar...@gmail.com> wrote:

> Got it. It is rolling. I thought it would limit across days, too. Is there
> a way to do cleanup across days currently?
> 
> Thank you.
> 
> - Arkin
> 
> On Tuesday, October 15, 2013, Ralph Goers wrote:
> 
>> What behavior are you seeing?  Is it never rolling or something else?
>> 
>> The max attribute only applies if you have a %i in the file pattern. It
>> would limit to 2 files per day if you had one in the patten, but not 2
>> files across days.
>> 
>> Ralph
>> 
>>> On Oct 14, 2013, at 6:07 PM, Arkin Yetis <arkinyetis@gmail.com<javascript:;>>
>> wrote:
>>> 
>>> Hi,
>>> I can't seem to get the DefaultRolloverStrategy to work with the
>> following
>>> configuration. Is there anything I am doing wrong?
>>> Thanks,
>>> Arkin
>>> 
>>>   <?xml version="1.0" encoding="UTF-8"?>
>>>   <configuration status="info" name="ABC" >
>>>     <appenders>
>>>       <RollingFile name="localFile" fileName="test.log"
>>> filePattern="test-%d{MM-dd-yyyy}.log.gz">
>>>         <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
>>> %M - %msg%n" />
>>>         <TimeBasedTriggeringPolicy />
>>>         <DefaultRolloverStrategy max="2" />
>>>       </RollingFile>
>>>     </appenders>
>>> 
>>>     <loggers>
>>>       <root level="info">
>>>         <appender-ref ref="localFile" />
>>>       </root>
>>>     </loggers>
>>>   </configuration>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org<javascript:;>
>> For additional commands, e-mail: log4j-user-help@logging.apache.org<javascript:;>
>> 
>> 


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


Re: roll over strategy question

Posted by Arkin Yetis <ar...@gmail.com>.
Got it. It is rolling. I thought it would limit across days, too. Is there
a way to do cleanup across days currently?

Thank you.

- Arkin

On Tuesday, October 15, 2013, Ralph Goers wrote:

> What behavior are you seeing?  Is it never rolling or something else?
>
> The max attribute only applies if you have a %i in the file pattern. It
> would limit to 2 files per day if you had one in the patten, but not 2
> files across days.
>
> Ralph
>
> > On Oct 14, 2013, at 6:07 PM, Arkin Yetis <arkinyetis@gmail.com<javascript:;>>
> wrote:
> >
> > Hi,
> > I can't seem to get the DefaultRolloverStrategy to work with the
> following
> > configuration. Is there anything I am doing wrong?
> > Thanks,
> > Arkin
> >
> >    <?xml version="1.0" encoding="UTF-8"?>
> >    <configuration status="info" name="ABC" >
> >      <appenders>
> >        <RollingFile name="localFile" fileName="test.log"
> > filePattern="test-%d{MM-dd-yyyy}.log.gz">
> >          <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
> > %M - %msg%n" />
> >          <TimeBasedTriggeringPolicy />
> >          <DefaultRolloverStrategy max="2" />
> >        </RollingFile>
> >      </appenders>
> >
> >      <loggers>
> >        <root level="info">
> >          <appender-ref ref="localFile" />
> >        </root>
> >      </loggers>
> >    </configuration>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org<javascript:;>
> For additional commands, e-mail: log4j-user-help@logging.apache.org<javascript:;>
>
>

Re: roll over strategy question

Posted by Ralph Goers <rg...@apache.org>.
What behavior are you seeing?  Is it never rolling or something else?

The max attribute only applies if you have a %i in the file pattern. It would limit to 2 files per day if you had one in the patten, but not 2 files across days.

Ralph

> On Oct 14, 2013, at 6:07 PM, Arkin Yetis <ar...@gmail.com> wrote:
> 
> Hi,
> I can't seem to get the DefaultRolloverStrategy to work with the following
> configuration. Is there anything I am doing wrong?
> Thanks,
> Arkin
> 
>    <?xml version="1.0" encoding="UTF-8"?>
>    <configuration status="info" name="ABC" >
>      <appenders>
>        <RollingFile name="localFile" fileName="test.log"
> filePattern="test-%d{MM-dd-yyyy}.log.gz">
>          <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36}:%L
> %M - %msg%n" />
>          <TimeBasedTriggeringPolicy />
>          <DefaultRolloverStrategy max="2" />
>        </RollingFile>
>      </appenders>
> 
>      <loggers>
>        <root level="info">
>          <appender-ref ref="localFile" />
>        </root>
>      </loggers>
>    </configuration>

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