c# - Castle ILogger and lazy loading Func<string> -
so using castle built in back upwards logging , chosen leverage nlog.
so have done reading nlog, seems want have of log messages wrapped in if block increment performance not computing value message unless needed. it, ugly makes sense.
if (logger.isinfoenabled) { logger.infoformat ( "some info message process running dates of {0} {1}", fromdate.tostring("mm/dd/yyyy"), todate.tostring("mm/dd/yyyy") ); } so digging in notice logger.info has overload (func) "lazy loaded". great, dont need have these if blocks everywhere =]
the question (i'm still getting used func[ing] go easy on me) phone call passed lazy load func or sent in string?
logger.info (string.format( "some info message process running dates of {0} {1}", fromdate.tostring("mm/dd/yyyy"), todate.tostring("mm/dd/yyyy") ));
your code missing brackets create func
logger.info(() => string.format( "check pam calendar holidays date range {0} {1}", fromdate.tostring("mm/dd/yyyy"), todate.tostring("mm/dd/yyyy") )); and right way write code - string.format method called if logger going log string.
c# nlog
No comments:
Post a Comment