logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: 1.3 {} notation available in 1.2.x?
Date Tue, 04 Sep 2007 04:46:42 GMT

On Sep 3, 2007, at 3:51 PM, Ceki Gulcu wrote:

>
> Curt Arnold wrote:
>> As Scott mentioned, the extras companion contains two utility  
>> classes to support parameterized logging, LogSF and LogMF.  LogSF  
>> uses the log4j 1.3 message patterns (curly braces, no argument  
>> count or qualifiers) and LogMF which uses the  
>> java.text.MessageFormat.  LogSF only justification is to support  
>> migration of existing log4j 1.3 code, if you were writing new  
>> statements, I would encourage you to use LogMF since  
>> java.text.MessageFormat's pattern syntax is part of the JDK, well  
>> documented and much richer.  As implemented  in LogMF and LogSF,  
>> there is no detectable performance difference between the two.
>
> In test I've done, LogSF aka SLF4J style curly braces perform much  
> better than
> java.text.MessageFormat, actually at least 10 times faster. Even  
> for *enabled*
> statements, taking into account the overall cost of a logging  
> statement (and
> actually writing to file or some other destination), the difference  
> remains
> significant. A SLF4J style logging will perform twice as fast for  
> enabled log
> statements and at least 10 times as fast for *disabled* log  
> statements.
>

LogMF does not use java.text.MessageFormat's implementation when  
presented with a trivial pattern like "hello, {0}" which bypasses the  
relatively expensive java.text.MessageFormat.format(String, Object)  
implementation (which appears to create an array and delegate to  
format(String, Object[]).  This was based on benchmark done and  
posted back in early 2006 (http://marc.info/?l=log4j- 
dev&m=113719664927002&w=2) with subsequent optimization described in  
http://marc.info/?l=log4j-dev&m=113753508714633&w=2.  I benchmarked  
the crude out of the code back when it was originally written based  
on your concerns and I doubt your comments reflect the current  
performance of LogMF.


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


Mime
View raw message