如果应用程序正在使用NLog,为什么要使用ELMAH [英] Why would one use ELMAH if the application is using NLog

查看:153
本文介绍了如果应用程序正在使用NLog,为什么要使用ELMAH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个集中式日志记录框架.

I have to write a centralized logging framework.

基本要求是

  • 记录异常以及其他详细信息(如果需要)到SQL Server DB.
  • 如果数据库关闭,即故障转移选项是登录到文件和电子邮件

我已经阅读了一番,看起来NLog是最好的选择,因为它简单易用,是我需要的大多数功能. 我的计划是围绕NLog编写包装类库,并在所有asp.net应用程序,Web api,其他库项目以及一些使用COM +的经典ASP网站中使用我的库.

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+.

但是我注意到有人提到使用ELMAH进行异常处理,使用NLog进行诊断.

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

我的问题(或者我应该说困惑):如果我正在使用NLog,为什么还要使用ELMAH?

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

或者什么时候将ELMAH与NLog一起使用?

Or when would one use ELMAH alongside NLog?

请注意,我不是要按功能比较功能,而是要了解:当一个人选择一个而不是另一个时会发生什么情况?除了ELMAH适用于Web应用程序.

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.

推荐答案

Elmah用于处理未捕获的异常,通常是最后一道防线",可以识别何时情况完全恶化.您可以在github页面上阅读它提供的内容: http://code.google.com/p/elmah /

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和其他(我强烈推荐Serilog)用于运行时诊断和跟踪...也就是说,转储正在跟踪或记录的信息(根据定义,这不是未捕获的异常).

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与log4net一样,nlog的使用时间已经相当长了,尽管有一个最新版本……一年前的上一个版本,但我感到大多数老套"日志记录框架并没有真正增长与时俱进.

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是一个更好的选择,因为它提供了结构化日志记录",例如,它使您可以搜索日志文件中的特定字段.

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.

这篇关于如果应用程序正在使用NLog,为什么要使用ELMAH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆