转储 Windows 服务日志文件的文件夹
简短: Windows 服务将日志文件转储到的最合适的文件夹是什么?
详细信息
我有一个 Windows 服务,可以生成低技术最终用户可能有兴趣查看的日志文件(计算机和生产线监控传感器之间的实际通信)。
该计算机是一台独立的专用计算机,充当数据采集服务器,它具有监视器并且可供最终用户访问,但除非出现问题否则不得触摸。
将这些日志文件输出到的最佳(最合适)位置(文件夹)是什么?
我的考虑因素是:
- 易于配置(以防我必须授予本地服务帐户对该文件夹的访问权限)。
- 最终用户易于访问(再次强调:他们不需要,但有时他们可能想要)。
编辑:它会创建大约 10 个最大 1Mb 的滚动大小文件。大小不存在问题,因此无需压缩和清理。
Short: What's the most appropriate folder for windows service to dump log files into?
Details
I have a windows service that produces log files that a low-tech end user might be interested to look at (actual communication between a computer and a manufacturing line monitoring sensors).
The computer is a stand-alone dedicated computer that acts as a data acquisition server, it has monitor and accessible to the end user, but not meant to be touched unless there are problems.
What's the best (most appropriate) place (folder) to output those log files to?
My considerations are:
- ease of configuration (in case I have to give an access for local services account to that folder).
- ease of access for an end user (again: they shouldn't need to, but occasionally they might want to).
EDIT: It creates about 10 up to 1Mb rolling size files. There is no issue with size, so no compression and clean-up is necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的偏好是使用“所有用户”文件夹结构。通过在其中创建一个与服务应用程序同名的文件夹,内容的来源一目了然,您可以授予对其的访问权限,而不会影响 Program Files 文件夹,并且当您卸载或升级应用程序时,您将不会离开Program Files 中的“孤立”文件夹无法删除,因为安装程序不知道必须删除一些日志文件。
My preference is to make use of the All Users folder structure. By creating a folder in there with the same name as your service app, it's readily apparent where the contents come from, you can grant access to it without compromising the Program Files folder, and when you uninstall or upgrade your app you won't leave 'orphan' folders in Program Files that couldn't be removed because the installer didn't know it had to delete some log files.
好吧,我会说你的服务安装在
/Logs/
文件夹中。然后添加功能以在稍后阶段压缩这些文件。通过这样做,您不会将应用程序数据与实际运行的应用程序分开。例如,将其保存到
C:\LogDumps\
不会表明哪个程序首先创建了这些文件,并且维护起来将是一场噩梦。Well, I'd say where your service installed to, in a
/Logs/
folder. Then add functionality to compress these files at a later stage.By doing this, you're not splitting up your applications data from the actual running application. For instance, saving this to
C:\LogDumps\
gives no indication of what program created the files in the first place and would be a nightmare to maintain.我认为最直观的记录位置是安装服务的文件夹中的子文件夹“Logs”。例如,如果服务安装在此处:
c:\program files\my company\my service\
将日志放在这里:
c:\program files\my company\my service\logs\
我不喜欢应用程序日志到“文档和设置”或“我的文档”区域 - 我不喜欢在本应是“我的文档”的文件夹中出现我没有创建的垃圾。
I think the most intuitive place to log is a sub-folder "Logs" within the folder where the service is installed. For example, if the service is installed here:
c:\program files\my company\my service\
Put the logs here:
c:\program files\my company\my service\logs\
I don't like it when applications log to the "Documents and Settings" or "My Documents" areas - I don't like having crap that I didn't create in a folder that is supposed to be My Documents.