[logback-user] commons-logging -> sl4j -> logback

Kristian Lind klpcrap at gmail.com
Thu Feb 7 22:35:59 CET 2013


And that is of cause no matter if there is sl4j behind the commons-logging
I guess ?

On Thu, Feb 7, 2013 at 1:11 PM, Brett Walker <brett.walker at geometryit.com>wrote:

> With log.debug("The object is " + object), it will always call .toString()
> on object because the string argument needs to be constructed before the
> call to .debug().
>
> To avoid this use either
>
>   If (log.isDebugEnabled()) {
>     Log.debug("The object is " + object);
>   }
>
> Or the slf/logback usage
>
>   Log.debug("The object is {0}", object);
>
> Which will delay the call to .toString() until it has determined that
> debug logging is needed.
>
> Brett
>
> Sent from my iPad
>
> On 08/02/2013, at 7:43 AM, "Kristian Lind" <klpcrap at gmail.com> wrote:
>
> In a previous project I switched from commons-logging -> log4j to sl4j ->
> logback.
> One of the reasons I did that was the overhead in log4j when providing a
> object in the log...
> log.debug("This is a object" + object);
> would cause the object.toString to be called even debug was not enabled.
>
> Now I work on a new project that uses commons-logging -> sl4j -> logback
> (jcl-over-slf4j)
>
> My question is now, will this still call object.toString.. even debug is
> not enabled
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> ....
> log.debug("This is a object" + object);
>
> I would like to get rid of commons-logging and jcl-over.sl4j and only have
> sl4j and logback.
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>



-- 
Med venlig hilsen / Best regards

Kristian Lind
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130207/ea931fd1/attachment-0001.html>


More information about the Logback-user mailing list