if( logger.IsDebugEnabled )

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

if( logger.IsDebugEnabled )


I'm new here, and I hopeto become a NLog user ;o)

For my first post, I would like to suggest you to add this thread
response to the page

I feel that it is a perfomance tips.


Here is your response :

You should use IsXXXEnabled when the time needed to construct the
parameters can be long:
if (logger.IsDebugEnabled)
    logger.Debug("The {0}-th Fibonacci number is {1}", i, Fib(i));
If there are no targets assigned to this (logger,level) combination, the
Debug() function will do nothing, but the compiler will have to generate
the code to call Fib(i), push the results on stack and so on. This can
be costly, so you should guard the logging call with the appropriate check.
In general, when you use parameters that are cheap to construct (local
variables, member fields, but not method calls) and you use one of the
supported overloads, things are very fast.

This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
Nlog-list mailing list
[hidden email]