Extending DailyRollingFileAppender - Apache

This is a discussion on Extending DailyRollingFileAppender - Apache ; I am interested in extending DailyRollingFileAppender. The existing appender can be configured to roll over at intervals like once a month, once a week, once a day, once a half-day (AM/PM), once a minute, etc. What I need is to ...

+ Reply to Thread
Results 1 to 4 of 4

Extending DailyRollingFileAppender

  1. Default Extending DailyRollingFileAppender

    I am interested in extending DailyRollingFileAppender. The existing
    appender can be configured to roll over at intervals like once a month,
    once a week, once a day, once a half-day (AM/PM), once a minute, etc.
    What I need is to be able to roll over at other intervals in between,
    such as every ten minutes. Does anyone know of an already-written
    appender that supports this? Alternatively, where can I find
    documentation of what I need to do to write a new appender (for log4cxx
    of course, as opposed to log4j), and what I'd need to change from
    DailyRollingFileAppender to support the added functionality?

    Thanks,

    Moshe



  2. Default Re: Extending DailyRollingFileAppender

    Log4cxx::rolling::RollingFileAppender is designed to use an arbitrary
    triggering policy. Drfa is just an instance precinfigured with a
    specific policy. Instead of writing a new appended, you should
    consider writing a custom triggering policy.

    On Jul 29, 2008, at 6:48 AM, "Moshe Matitya"
    <Moshe.Matitya@Kayote.com> wrote:

    > I am interested in extending DailyRollingFileAppender. The existing
    > appender can be configured to roll over at intervals like once a
    > month,
    > once a week, once a day, once a half-day (AM/PM), once a minute, etc.
    > What I need is to be able to roll over at other intervals in between,
    > such as every ten minutes. Does anyone know of an already-written
    > appender that supports this? Alternatively, where can I find
    > documentation of what I need to do to write a new appender (for
    > log4cxx
    > of course, as opposed to log4j), and what I'd need to change from
    > DailyRollingFileAppender to support the added functionality?
    >
    > Thanks,
    >
    > Moshe
    >



  3. Default RE: Extending DailyRollingFileAppender

    I've been browsing the code, and things aren't quite clear to me. It
    seems to me that I'd also need to write a custom rolling policy, in
    order to deal with formatting the file name, no? (If the file is
    rolling over every 10 minutes, say, then we'd need to modify the file
    names accordingly.) And that looks like it might require changing
    FormattingInfo and/or PatternConverter, no? Or can that be left alone?

    Is there some sample code anywhere for doing something similar that can
    be used as an example of the things that need to be changed?

    Thanks,

    Moshe


    On Tuesday, July 29, 2008 3:02 PM, Curt Arnold wrote:
    >
    > Log4cxx::rolling::RollingFileAppender is designed to use an arbitrary
    > triggering policy. Drfa is just an instance precinfigured with a
    > specific policy. Instead of writing a new appended, you should
    > consider writing a custom triggering policy.
    >
    > On Jul 29, 2008, at 6:48 AM, "Moshe Matitya"
    > <Moshe.Matitya@Kayote.com> wrote:
    >
    > > I am interested in extending DailyRollingFileAppender. The existing
    > > appender can be configured to roll over at intervals like once a
    > > month,
    > > once a week, once a day, once a half-day (AM/PM), once a minute,

    etc.
    > > What I need is to be able to roll over at other intervals in

    between,
    > > such as every ten minutes. Does anyone know of an already-written
    > > appender that supports this? Alternatively, where can I find
    > > documentation of what I need to do to write a new appender (for
    > > log4cxx
    > > of course, as opposed to log4j), and what I'd need to change from
    > > DailyRollingFileAppender to support the added functionality?
    > >
    > > Thanks,
    > >
    > > Moshe
    > >



  4. Default Re: Extending DailyRollingFileAppender

    On Tue, Jul 29, 2008 at 9:28 AM, Moshe Matitya <Moshe.Matitya@kayote.com> wrote:
    > I've been browsing the code, and things aren't quite clear to me. It
    > seems to me that I'd also need to write a custom rolling policy, in
    > order to deal with formatting the file name, no? (If the file is
    > rolling over every 10 minutes, say, then we'd need to modify the file
    > names accordingly.) And that looks like it might require changing
    > FormattingInfo and/or PatternConverter, no? Or can that be left alone?
    >
    > Is there some sample code anywhere for doing something similar that can
    > be used as an example of the things that need to be changed?
    >
    > Thanks,
    >
    > Moshe
    >
    >
    > On Tuesday, July 29, 2008 3:02 PM, Curt Arnold wrote:
    >>
    >> Log4cxx::rolling::RollingFileAppender is designed to use an arbitrary
    >> triggering policy. Drfa is just an instance precinfigured with a
    >> specific policy. Instead of writing a new appended, you should
    >> consider writing a custom triggering policy.
    >>
    >> On Jul 29, 2008, at 6:48 AM, "Moshe Matitya"
    >> <Moshe.Matitya@Kayote.com> wrote:
    >>
    >> > I am interested in extending DailyRollingFileAppender. The existing
    >> > appender can be configured to roll over at intervals like once a
    >> > month,
    >> > once a week, once a day, once a half-day (AM/PM), once a minute,

    > etc.
    >> > What I need is to be able to roll over at other intervals in

    > between,
    >> > such as every ten minutes. Does anyone know of an already-written
    >> > appender that supports this? Alternatively, where can I find
    >> > documentation of what I need to do to write a new appender (for
    >> > log4cxx
    >> > of course, as opposed to log4j), and what I'd need to change from
    >> > DailyRollingFileAppender to support the added functionality?


    The existing code can easily handle rolling over every 10 minutes. It
    can handle rolling over any time when part of a timestamp changes.

    The way it works is that you specify a file name format that includes
    a date format parameter in the file name. You don't include anything
    in the data format that is less than the digit you want to change.
    It's much easier to see by example:

    So the date format is the same as in pattern layout (Tip: don't use :
    or / in your date format, as these are not valid filenames).

    This would roll over every millisecond:

    log-%d{dd-MMM-yyyy-HH_mm_ss_SSS}.log

    To change the period for rollover just remove parts of the date
    format. It rolls over when the filename would be different so removing
    parts of the format keeps it the same.

    This would rollover every second:

    log-%d{dd-MMM-yyyy-HH_mm_ss}.log


    This would rollover every hour:

    log-%d{dd-MMM-yyyy-HH}.log

    This should rollover every 10 minutes I think:

    log-%d{dd-MMM-yyyy-HH_m}0.log


    --
    Dale King


+ Reply to Thread