views:

360

answers:

2

We have a very high-performance multi-threaded .NET HTTP handler application and want to enable trace logging for debugging. I have a few questions about this:

  • Is tracelevel the best way to toggle on/off logging?
  • If tracelevel is "off," will the tracelevel statements have any impact on performance?
  • When using an HTTP handler, how can I view the trace log real-time?
  • Is the Enterprise Library overkill for this? Does it provide any overhead?
+1  A: 

Log4net

NTulip
A: 

Enterprise Library seems overkill in many cases, but that might just be the daunting configuration.

log4net is great. The way they provide a "no perf impact" logging experience is by predicating calls to the logger off of a static readonly variable. Since the static readonly variable gets set during initialization of your type, supposedly the JIT can take this into consideration and simply remove the call to the logger in the case. Do note that this means you can't reconfigure on the fly.

Another option is Event Tracing for Windows (ETW). Performance is tuned for kernel use and supposedly outstanding:

"We've achieved 20,000 events per second while only using 5% CPU load on a P3 500MHz!" (From http://blogs.msdn.com/ryanmy/archive/2005/05/27/422772.aspx)

However, the .NET integration will add some overhead, and the .NET integration isn't very pleasant, either, IMO. On the plus side, you can integrate well into the Windows event log system, and have the system admins turn different logging on and off in production -- without having to use specialized tools for your application.

MichaelGG