On Thu, Mar 27, 2008 at 8:15 PM, Ceki Gulcu <[EMAIL PROTECTED]> wrote:

>
> Yes, "count += string.length()" statement could be replaced by "count +=
> string.getBytes(encoding).length" which would probably be faster than
> calling
> file.getSize.
>
> However, given that size based rolling policy is less popular then date
> based
> rollovers, I am inclined to just ignore the issue (of performance).


Hello Ceki,

I have no idea which one is more popular, but I prefer a combination of the
two:
decision on rolling file-based but naming of rolled files date-based.

Unfortunately I had to roll my own version of TimeBasedRollingPolicy
because the 'standard' one is also a TriggeringPolicy.

The combination of MyTimeBasedRollingPolicy and MySizeBasedTriggeringPolicy
is working just fine,  but it would be great to see this functionality in
logback.

I should note that I have implemented these classes for log4j, but I also
had a look at logback
(it could have been an extra reason to finally make the switch to logback)
but AFAICS it has the same problem: TimeBasedRollingPolicy implements
TriggeringPolicy.

Kind regards,
Maarten


>
> Maverick Crank GRey wrote:
> > Hello Ceki,
> >
> > On Thu, Mar 27, 2008 at 4:31 PM, you wrote:
> >
> >     By character set, I actually meant character encoding, e.g. ASCII,
> >     UTF-8.
> >
> >
> > Oh, I see. Actually, I was addled by your "whereas log4j's
> > implementation actually counts the number of *bytes* written". Looking
> > into the org.apache.log4j.helpers.CountingQuietWriter, I have found the
> > following code:
> > ===
> >   public
> >   void write(String string) {
> >     try {
> >       out.write(string);
> >       count += *string.length()*;
> >     }
> >     catch(IOException e) {
> >       errorHandler.error("Write failure.", e, ErrorCode.WRITE_FAILURE);
> >     }
> >   }
> > ===
> > Am I right that it is possible to replace '.length()' with
> > '.getBytes(suitableCharsetName).length' to be sure in real size (in
> > bytes) of written string? Can it be faster than calling file.getSize()?
> >
> > suitableCharsetName can be a system charset or specified by
> >
> http://logback.qos.ch/apidocs/ch/qos/logback/core/WriterAppender.html#encoding
> > --
> > Be Happy!!!
> > UIN ICQ: 9487080
> > JUD: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > logback-dev mailing list
> > [email protected]
> > http://qos.ch/mailman/listinfo/logback-dev
>
> --
> Ceki Gülcü
> QOS.ch is looking to hire talented developers in Switzerland.  If
> interested, please contact c e k i @ q o s . c h
>
> _______________________________________________
> logback-dev mailing list
> [email protected]
> http://qos.ch/mailman/listinfo/logback-dev
>
_______________________________________________
logback-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-dev

Reply via email to