Why would one use ELMAH if the application is using NLog

一世执手 提交于 2019-12-04 16:46:24

问题


I have to write a centralized logging framework.

Basic requirements are:

  • Log exceptions as well as other details if needed to SQL Server DB.
  • If DB is down i.e. a failover option is to log to a file and email

I had done some reading around and looks NLog is the best option being simple and most features I need. My plan is to write a wrapper class library around NLog and use my library in all my asp.net applications, web api as well as other library projects and some classic asp sites using COM+.

But I noticed some people mentioning using ELMAH for exception handling and NLog for diagnostics.

My Question(or I should say confusion): Why would I use ELMAH if I am using NLog?

Or when would one use ELMAH alongside NLog?

Or

Note I am not trying to compare the features-by-feature but want to understand: What would be the scenario when one would opt for one over other? Except the fact that ELMAH is for web applications.


回答1:


Elmah is used for handling uncaught exceptions, and is generally a "last line of defense" to be able to identify when things go completely belly up. You can read what it provides on its github page: http://code.google.com/p/elmah/

NLog and others (I highly recommend Serilog) are used for runtime diagnostics and tracing... That is, to dump information which you are either tracing, or logging (which is, by definition, not uncaught exceptions).

NLog, as like log4net, nlog is getting quite long in the tooth and while there was a recent release... the previous release a year earlier, and I feel most of the "old guard" logging frameworks have not really grown with the times.

Serilog is a much better choice, as it provides "structured logging" which allows you to, for example, search on specific fields in the log files.




回答2:


Erik hit it on the head as to why someone would use both. However, ReflectInsight is a much better choice for structured logging and exception trapping. https://insightextensions.codeplex.com



来源:https://stackoverflow.com/questions/28666473/why-would-one-use-elmah-if-the-application-is-using-nlog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!