logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale King" <dalewk...@gmail.com>
Subject Re: TimeBased + SizeBased
Date Mon, 29 Sep 2008 15:28:23 GMT
You can't with log4cxx as it exists. You don't want TimeBasedRollingPolicy.
You want SizeBasedTriggeringPolicy with FixedWindowRollingPolicy. But
FixedWindowRollingPolicy only supports the index format specifier. If you
subclassed FixedWindowRollingPolicy  and overrode getFormatSpecifiers to be
something like this:

  PatternMap specs;
  RULES_PUT("i", IntegerPatternConverter);
  RULES_PUT("index", IntegerPatternConverter);
  RULES_PUT("d", FileDatePatternConverter);
  RULES_PUT("date", FileDatePatternConverter);
  return specs;

You could get close. I'll bet though it probably will not work completely
like you think it will. For instance it will only start a new log file when
the size is exceeded. So if there are few messages you could have the same
log file for weeks.

I think there is definitely some room for improvement in the area of
policies. For example, TimeBasedRollingPolicy cannot be used as a triggering
policy unless it is also the rolling policy. If you do, once it triggers it
will trigger for every message thereafter.

On Thu, Sep 25, 2008 at 3:54 PM, Alex Rosenbaum <
Alex.Rosenbaum@thomsonreuters.com> wrote:

>  I am trying to implement logging to rolling files. I want rollover to
> occur when the size reaches certain limit. At the same time I'd like file
> name to include date stamp, so the result looks like:
> MyLog.2008-09-08.log
> MyLog.2008-09-08.1.log
> MyLog.2008-09-08.2.log
> ... etc.
> I started with log4cxx::RollingFileAppender, but it doesn't seem to support
> FileName patterns.
> Next, I tried log4cxx::rolling::RollingFileAppender with
> TimeBasedRollingPolicy. This option does not allow rollover to be triggered
> by file size.
> Next, I tried log4cxx::rolling::RollingFileAppender with
> TimeBasedRollingPolicy and SizeBasedTriggeringPolicy, but it seemed to
> create a conflict because TimeBasedRollingPolicy also sets Triggering policy
> for the appender.
> What is the solution I am looking for?
>  *Alex Rozenbaum*
> Consultant
> *Thomson Reuters*
> Phone: 646-822-2821
> alex.rosenbaum@thomsonreuters.com
> thomsonreuters.com
> This email was sent to you by Thomson Reuters, the global news and
> information company.
> Any views expressed in this message are those of the individual sender,
> except where the sender specifically states them to be the views of Thomson
> Reuters.

Dale King

View raw message