Logging and performance

Topics: Logging Application Block
Jan 13, 2010 at 8:58 AM

Hi, I need to use logging in a performance critical application ( 1000 ms round trip from hardware ->client->database), all the normal logging is fine, but when i need to serialize something for example its expensive and does not need to run every time only when the logging level is as such. So the expensive method basically runs every time and is then discarded later. Is there a way to get it to only run when the trace level matches or maybe wrap it in an if and compare the trace level (Like the TRACE and DEBUG globals) ?


_logger.Log(string.Format("Some info about {0} and validation result {1}", someExpensiveMethod(), Category.Trace, Priority.None);

Jan 13, 2010 at 3:37 PM


Try setting the "Filter" property of the trace listener. This will filter the entries that will be accepted and logged by the trace listener. Please see this: http://entlib.codeplex.com/Thread/View.aspx?ThreadId=44442

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.