See the LogMF or LogSF classes. LogMF used MessageFormat type format
specifiers ("{1}") while LogSF uses SLF4J format specifiers ("{}") .
varargs were introduced in Java 5 and have an unavoidable array
construction/destruction expense even if the level is not reached. The LogMF
and LogSF classes approximate the usability of varargs by having a lot of
different signatures.
On Apr 4, 2011, at 10:27 AM, <[email protected]>
<[email protected]> wrote:
> Hi,
> why don't we add a method in the Logger class or at least a Util with a
> method like the following one in order to avoid the cost of the message build.
> In this way we'll not have to build the message unless the priority is
> enabled for the logger.
>
> I'll wait for your thoughts.
>
> Regards,
>
> import org.apache.log4j.Logger;
> import org.apache.log4j.Priority;
>
> public class LoggerUtil {
>
> static public void log(Logger logger, Priority priority, Object... objs){
>
> if (logger.isEnabledFor(priority) ){
> StringBuffer sb = new StringBuffer();
> for(Object obj : objs){
> sb.append( obj.toString() );
> }
> logger.log(priority, sb.toString() );
> }
> }
> }
>
>
> Cusano Pineda, Gerardo H.
> Information System Engineer
> Accenture – System Integration & Technology
> Buenos Aires, Argentina
> * [email protected]
>
> This message is for the designated recipient only and may contain privileged,
> proprietary, or otherwise private information. If you have received it in
> error, please notify the sender immediately and delete the original. Any
> other use of the email by you is prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]