网站日志(IIS7,托管)

发布于 2024-08-19 09:37:39 字数 224 浏览 5 评论 0原文

我有一个托管在 webhost4life 的 ASP.NET MVC 应用程序
保存日志的好方法是什么?
我可以访问我上传网站的 ftp,我应该有效地做

 File.AppendAllText("log.txt", "Ooops, we have an error" + e.Message);

还是有更好的方法?发送电子邮件?将日志保存到数据库中?

I have an ASP.NET MVC app hosted at webhost4life
What's a good way to save logs?
I have an access to the ftp I upload site to, should I just do effectively

 File.AppendAllText("log.txt", "Ooops, we have an error" + e.Message);

Or is there a better way? Send e-mail? save log into a database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我乃一代侩神 2024-08-26 09:37:39

我总是尝试登录数据库并在数据库无法访问时退回到文件(也许这就是异常的原因)。这使您可以直接针对日志运行查询和报告,并立即找出问题所在。您还可以通过存储关键异常并对其进行标记等来对应用程序运行“健康检查”。

I always try to log to a database and fall back on a file if the database is inaccessible (perhaps that's the cause of the exception). This allows you to run queries and reporting against the log directly and find out what the problem is immediately. You can also run a "health check" against the application by storing critical excepions and marking them, etc.

紫﹏色ふ单纯 2024-08-26 09:37:39

避免写入文件系统;这可能会在尝试写入同一文件的线程之间产生冲突/竞争条件。数据库是解决这个问题的绝佳解决方案,并提供了一些很好的好处,例如能够从标准化数据轻松生成报告。

另外,您正在记录什么样的信息? IIS日志非常详细。保存这些日志中已有的信息会重复工作(服务器写入其日志,然后您编写自己的日志),这当然会导致性能下降。

Avoid writing to the file system; this can generate collisions/race conditions between threads that are attempting to write to the same file. Databases are wonderful solutions for this problem, and provide some nice benefits such as being able to generate reports easily from normalized data.

Also, what sort of information are you logging? The IIS logs are very detailed. Saving information that is already available in those logs duplicates work (the server writes its logs, and then you write your own), which of course incurs a performance hit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文