在Windows中写错误日志的最佳位置在哪里? [英] Where are the best locations to write an error log in Windows?

查看:147
本文介绍了在Windows中写错误日志的最佳位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,您将在何处写入错误日志文件(例如ErrorLog.txt)?请记住,该路径需要向基本用户开放以获取文件写入权限.

Where would you write an error log file, say ErrorLog.txt, in Windows? Keep in mind the path would need to be open to basic users for file write permissions.

我知道事件日志是写错误的可能位置,但是它对用户"级别的权限有效吗?

I know the eventlog is a possible location for writing errors, but does it work for "user" level permissions?

我的目标是Windows 2003,但是我提出问题的方式是要有一个通用指南",用于在哪里写错误日志.
至于EventLog,以前在ASP.NET应用程序中曾想登录Windows事件日志,但我遇到了安全问题,这使我心痛. (我不记得遇到过的问题,但记得遇到过这些问题.)

I am targeting Windows 2003, but I was posing the question in such a way as to have a "General Guideline" for where to write error logs.
As for the EventLog, I have had issues before in an ASP.NET application where I wanted to log to the Windows event log, but I had security issues causing me heartache. (I do not recall the issues I had, but remember having them.)

推荐答案

您是否考虑过记录事件查看器?如果要编写自己的日志,建议用户使用本地应用程序设置目录.在该目录下创建一个产品目录.在不同版本的Windows上是不同的.

Have you considered logging the event viewer instead? If you want to write your own log, I suggest the users local app setting directory. Make a product directory under there. It's different on different version of Windows.

在Vista上,您不能将这样的文件放在c:\ program文件下.您将遇到很多问题.

On Vista, you cannot put files like this under c:\program files. You will run into a lot of problems with it.

在.NET中,您可以使用以下命令找到此文件夹:

In .NET, you can find out this folder with this:

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

事件日志也非常易于使用:

And the Event Log is fairly simple to use too:

http://msdn.microsoft.com/en -us/library/system.diagnostics.eventlog.aspx

这篇关于在Windows中写错误日志的最佳位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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