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 Mon, 03 Sep 2007 05:38:38 GMT

On Sep 2, 2007, at 3:13 PM, dirk ooms wrote:

> Hi,
>
> i was using log4j 1.3, but  i am moving back to 1.2.15 now. i often  
> used the
> {} symbols in my log statements, e.g. logger.info("blahblah {}",  
> value);
>
> 1.2.x does not seem to understand this. is there any extension to  
> 1.2.x that
> supports this notation?
>

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.

Basically, your:

logger.info("blahblah {}", value);

becomes

LogSF.info(logger, "blahblah {}", value);

A couple of regex search and replaces should be able to convert a  
code base pretty quickly.  If someone wants to donate a conversion  
script, please feel free.  A little perl script would likely work for  
most cases, or you could write up something with Eclipse's (or maybe  
NetBeans) refactoring capabilities.







---------------------------------------------------------------------
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