Windows 事件日志与文本日志

发布于 2025-01-03 00:24:01 字数 219 浏览 2 评论 0原文

我希望能就这个伟大的问题得到一些明确的答案。在 .net 中编写 Web 应用程序时,您应该使用 IIS 访问日志中的追加功能来存储您想要的内容,还是应该写入 Windows 事件日志?

我说的是信息日志记录、警告日志记录和错误日志记录。将其拆分并同时写入 iis 日志和事件日志是否明智?

或者对于普通的 .net windows 应用程序来说,它们应该写入自己的日志文件还是使用事件日志?

I'm hoping to get some definitive answers on this great question. When writing web applications in .net, should you use the append feature in the IIS access log to store what you want or should you write to the windows event log?

I'm talking about informational logging, warning logging and error logging. Would it be smart to split it up and write to both the iis log and event log?

Or for that matter for normal .net windows applications, should they write to their own log file or use the event log?

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

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

发布评论

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

评论(1

白鸥掠海 2025-01-10 00:24:01

我建议您不要将应用程序特定的日志信息放入 II 日志文件中。
该日志文件特定于 Web 服务器,并且该日志文件的格式由 II 中的日志设置决定。可以使用第 3 方日志分析工具,但您可能会遇到这些工具无法解析 II 日志文件的情况,因为您放置在那里的信息可能格式错误。

应用程序特定的日志信息最好分为事件日志或专用日志文件。是否应该是事件日志实际上是一个偏好问题。事件查看器可以更轻松地解析和过滤事件日志信息,因此更容易处理。这是一种众所周知的格式,您可以将其发送给其他人进行进一步调查,他们可以轻松地将其加载到事件查看器中。支持案例的绝佳选择。
如果您期望登录日志,最好创建专用的应用程序特定事件日志,这样您就不会弄乱通用应用程序事件日志。

我想说 Windows 桌面应用程序也是如此。

如果您还没有这样做,我还建议您使用众所周知的日志记录框架之一,例如 Log4Net 或企业日志块。这将为您节省大量时间和痛苦。

I would advice you to not put your application specific log information in the IIs log file.
That log file is specific to the web server and the format of that log file is determined by the log settings in IIs. 3rd party log analyzing tools are available for it, and you may ending up in a situation where these tools can not parse the IIs log files because information you have put there could be mis-formatted.

Application specific log information is better to separate into either the Event log or a dedicated log file. Whether it should be the Event log or not is really a matter of preference. The Event log information could more easily be parsed and filtered by the Event Viewer and therefore could be much easier to deal with. It's a well known format that you can send to other people for further investigation and they can easily load that up into their Event Viewer. Excellent choice for support cases.
If you expect a log of loggin it's preferable to create dedicated application specific Event log so you don't clutter the generic Application Event log.

I would say that this is true for Windows desktop applications as well.

If you don't already, I would also recommend you to use one of the well known logging frameworks such as Log4Net or the Enterprise Logging Block. It will save you a lot of time and pain.

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