我正在创建Web应用程序,我希望系统能够记录每个主要功能。 [英] I am creating web application, and I wanted system to Log each and every major Function.

查看:77
本文介绍了我正在创建Web应用程序,我希望系统能够记录每个主要功能。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想记录内容(asp.net中的任何错误或成功操作),这是执行此操作的最佳方法。



我知道一种文件处理方法。



谢谢

Hi All,

I wanted to Log the things (any error or successful operation in asp.net), so which is the best approach for doing this.

I know one method which is file handling.

Thanks

推荐答案

1)对于记录未处理的异常(红色屏幕),您可以使用ELMAH或NLog等日志工具。我建议使用ELMAH,因为它只需要通过Nuget软件包进行安装,并提供数据库,文本文件,电子邮件等的日志记录。您还可以访问前端,查看异常消息。

2)如果您希望在数据库级别进行CRUD日志记录,可以通过多种方式完成。您可以使用SQL触发器在单独的表中记录每个操作。
1) For logging un handled exceptions (red screens) you can use a logging facility such as ELMAH or NLog. I would recommend ELMAH as it is zero effort to install via a Nuget package & provides logging to database, text file, email etc. You also get a front end which you can access to view exception messages.
2) If you want CRUD logging at database level this can be done multiple ways. You can use SQL triggers to log every operation in separate table.


获取日志记录框架,例如Log4Net( http://logging.apache.org/log4net/ [ ^ ])。

手动将日志语句添加到所有这些函数,或使用面向方面编程添加它们方法(一些依赖注入/反转控制容器,如Unity( http://unity.codeplex.com/ [ ^ ])提供拦截,允许在调用函数/属性时添加额外的功能。)
Get a logging framework, e.g. Log4Net (http://logging.apache.org/log4net/[^]).
Add logging statements to all those functions manually, or add them using Aspect Oriented Programming methods (some Dependency Injection / Inversion of Control containers like Unity (http://unity.codeplex.com/[^]) offer "interception" which allows for adding extra functionality when a function / property is called).


尝试使用ASP.NET和C#创建简单的错误日志文件 [ ^ ]


这篇关于我正在创建Web应用程序,我希望系统能够记录每个主要功能。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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