1

我正在使用 asp.net 构建一个相当大的站点(如果有任何兴趣,可以使用表单),我想知道我是否需要一个日志框架,例如 log4net。我以前使用过这样的框架,但我不知道如何将它用于此类项目。通常我认为客户交付的应用程序需要日志记录,可以将日志发送回然后分析错误。你怎么看?

4

4 回答 4

6

哎呀,日志记录对于 Web 应用程序非常重要。如果您正确登录,它会使故障排除变得更加容易。

Log4Net 作为一个框架可能是一个不错的选择。您可能还需要一种从多个服务器收集日志的方法——即使您目前不使用多个服务器,也可能值得建议您在某个时候这样做。

集中化的一种选择是将日志复制到数据库中 - 有关这方面的更多意见,请参阅此问题。

于 2008-11-29T11:49:35.160 回答
2

所有类型的应用程序都需要日志。如果您交付您的应用程序(无论是客户交付的还是内部交付的),无论是 Web 表单还是 smartclient/windows 应用程序日志记录/仪器都是它的支柱。

您的应用程序的最终用户如何知道应用程序正在按预期工作?如果发生任何错误会发生什么?生产团队将如何诊断错误?最终用户/管理员将如何主动分析应用程序并防止未来可能出现的问题?

由于您使用的是 ASP.net,我建议您也看看 ASP.net 的“健康监控”功能。

您可以为不同类型的日志记录编写自定义事件和提供程序,并可以将其配置为同步/异步使用。

您可以将 log4net 或企业日志记录块与“健康监控”一起使用,并且可以以最小的努力创建一个全面的日志记录/仪表解决方案。

于 2008-11-29T11:56:18.767 回答
1

我肯定会担保企业信息接收器(我认为这是正确的名称,它是用于日志记录的 Microsoft api)或企业库。

I use the latter for all sorts of things such as caching, logging, etc, and it is a very powerful and time saving tool. I also use health monitoring. This is for a large web application that I am building.

You are spoilt for choice when it comes to logging in .NET, and the above two suggestions are great.

于 2008-11-29T12:01:49.817 回答
1

Logging is needed if you need to know how application behaves, in which conditions errors occur, who and how has used application (ip address, time, link,...)

Most people use it to trace program execution so they can answer questions like 'why it stopped working?', 'when did it stopped working?' etc.

If you know that applications code too well, and you can easily reproduce problems then I guess logging is overkill for you :)

于 2008-11-29T13:33:29.943 回答