NLOG,ELMAH +共享库 [英] NLog, Elmah + shared library

查看:112
本文介绍了NLOG,ELMAH +共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图想出一个方法来创建为我所有的MVC项目公用库。我开始真的BaseController和BaseModel类简单。简单的东西!

I am trying to come up with a way to create a common library for all my MVC projects. I started off really simple with BaseController and BaseModel classes. Easy stuff!

现在在我的项目,我想要么使用ELMAH或NLOG用于记录异常和/或追踪信息。

Now in my projects I would like to either use Elmah or NLog for logging exceptions and/or tracing info.

谁能给我上的最佳实践的一些想法写一个通用库支持?

Can anyone give me some ideas on the best practices for writing a common library to support both?

推荐答案

我会用NLOG为基础为您记录。我创建了一个NLOG小目标可能被用于路由例外ELMA。您将在 https://github.com/ccellar/nlog-elmah-target

I would use NLog as base for your logging. I've created a small target for NLog which could be used to route exceptions to ELMA. You'll find it at https://github.com/ccellar/nlog-elmah-target.

有了这个目标,你就可以使用记录仪。*异常(...)来记录异常,并把它传递给ELMAH。

With this target you are able to use logger.*Exception( ... ) to log the exception and to pass it to ELMAH.

这篇关于NLOG,ELMAH +共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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