0

Answers to this stackoverflow question discuss how to use Elmah to manually or programmatically log a handled exception but do not discuss cost. What is the (theoretical) difference in cost between using the following for logging a handled exception?

  • Elmah's ErrorSignal.Raise
  • Elmah's ErrorLog.Log
  • System.Diagnostics.TraceSource (or some other logging library)
Community
  • 1
  • 1
LandedGently
  • 693
  • 1
  • 8
  • 16

1 Answers1

1

This is not really an answer to your question, but rather a discussion point. Why is it important to know the cost (in terms of execution time, I assume?) of using Elmah?

This might be a case of premature optimization. A hundred milliseconds here or there shouldn't matter, unless within a tight, long loop. If your application throws enough errors that Elmah's added cost accumulates to the point of dragging performance down, it is my opinion that you should instead be looking at WHY so many exceptions are being thrown.

Is it to defend its use to your peers? Most logging blocks will exhibit very similar performance characteristics, one of the biggest factors being the location or nature of the log destination. I/O operations like writing logs to disk or to a network destination will take far more time than the rest of the logging code.

Maxam
  • 4,043
  • 2
  • 24
  • 25
  • Curious as to the distinction between Elmah's Raise and Log methods. Also I'm considering the possibility of using Elmah as a general-purpose logger; therefor curious about the difference between Elmah and TraceSource. – LandedGently Dec 06 '12 at 21:10
  • BTW, excellent point about the location of the log destination and I/O operations. – LandedGently Dec 06 '12 at 21:11
  • 2
    Ah, I see. I suggest rewording your question, then. The Raise method allows multiple listeners to be notified, while the Log method logs directly to the log target and bypasses any filter rules you've set up. – Maxam Dec 07 '12 at 02:39