Hello Ceki,

On Thu, Mar 27, 2008 at 1:54 PM, you wrote me:

> The difference in performance you observe is due to the fact that
> logback's size
> based triggering policy track file size by calling file.getSize() whereas
> log4j's implementation actually counts the number of bytes written. The
> latter
> is faster but may be off for certain character sets.


It sounds strange for me. I set triggeringPolicy in MB (megabytes)
===
        <triggeringPolicy class="
ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>100MB</MaxFileSize>
        </triggeringPolicy>
===
So what do you mean by 'character sets'? Do characters have really matter in
case I set file size in bytes?

If you try other appenders, or a rolling file appender with a different
> policy,
> e.g. date based, the performance numbers should be comparable or in
> logback's favor.


You are right.
With the following configs:
= logback.xml =
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug='true'>
    <appender name="logfile" class="
ch.qos.logback.core.rolling.RollingFileAppender">
        <File>logback.log</File>
        <BufferedIO>true</BufferedIO>
        <ImmediateFlush>true</ImmediateFlush>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss} - %m%n</pattern>
        </layout>
        <rollingPolicy class="
ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
        </rollingPolicy>
    </appender>
    <root>
        <!--<level value="info"/>-->
        <appender-ref ref="logfile"/>
    </root>
</configuration>
===
and
= log4j.properties =
log4j.rootCategory=debug, logfile

log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=log4j.log
log4j.appender.logfile.BufferedIO=true
log4j.appender.logfile.ImmediateFlush=true
log4j.appender.logfile.datePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{HH:mm:ss} - %m%n
===
I have got the following result for logback:
===
###############################################
One slf4j direct debug call: 2890 nanoseconds
One slf4j tested (isDebugEnabled) debug call: 3110 nanoseconds
One slf4j parametrized debug call: 3377 nanoseconds
###############################################
===
and one for log4j
===
###############################################
One slf4j direct debug call: 3743 nanoseconds
One slf4j tested (isDebugEnabled) debug call: 3742 nanoseconds
One slf4j parametrized debug call: 4230 nanoseconds
###############################################
===
And now I can see that logback is faster =)

But an issue with SizeBasedTriggeringPolicy is still opened for me.
-- 
Be Happy!!!
UIN ICQ: 9487080
JUD: [EMAIL PROTECTED]
_______________________________________________
logback-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-dev

Reply via email to