logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Pluggable message formats?
Date Fri, 10 Aug 2012 07:04:37 GMT
I created StringFormattedMessage and tested it. It is anywhere from 5 to 10 times slower than
ParameterizedMessage on my Mac.  But it is there if you want to use it.

Ralph

On Aug 9, 2012, at 10:08 PM, Paul Benedict wrote:

> On Thu, Aug 9, 2012 at 4:32 PM, Ralph Goers <ralph.goers@dslextreme.com> wrote:
>> This topic has come up several times, although your request seems slightly different.
>> 
>> Every log event in Log4j 2 is handled by a message object.  When you specify logger.debug("",
p1, p2) that gets converted essentially to logger.debug(new ParameterizedMessage("", p1, p2));
.  So if you want to use a different message format you could create a JavaStringMessage and
just do logger.debug(new JavaStringMessage("", p2, p2));
>> 
>> Most proposals to date have asked to use String.format for the whole String while
you seem to be suggesting that each item within {} be replaced by whatever String.format returns
from the single parameter passed to it.  I would think that would be slower than handling
the whole String.
>> 
>> Ceki has tested java.text.MessageFormat and said that it is at least 10 times slower
than the way ParameterizedMessage work.  I don't know if he, or anyone else, has compared
Formatter or String.format against ParameterizedMessage but I'd find it hard to believe it
isn't considerably slower also.  That said, if someone wants to implement it I have no problem
adding it.  If it is demonstrated to be nearly the same speed I would also have no problem
making it the default.
>> 
>> Ralph
> 
> Good points. Message formatting speed isn't too much of my concern
> since most of my logging is solely for DEBUG/TRACE level. I will
> investigate if there's a happy medium and get back to you.
> 
> Paul
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 


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


Mime
View raw message