用C#创建日志文件 [英] Create Log Files in C#

查看:79
本文介绍了用C#创建日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#创建Winforms应用程序。我想要实现的是在应用程序中发生错误和异常的日志文件创建。



此应用程序将由具有有限访问权限的用户使用Windows系统。

所以我想确保在用户无法写入或删除它的位置创建日志文件,我不希望获得未经授权的访问异常或说错误创建日志文件时。



简而言之,Windows系统中哪个位置最适合为使用此应用程序的每个用户创建日志文件。



请指教。



提前致谢。

解决方案
简单。使用windows事件日志



这里有一篇关于如何使用它的文章



如何创建Windows事件日志并将自定义消息写为好吧 [ ^ ]



这是否符合您的需求?


I am creating an Winforms Apps using C#. What i am trying to implement is the Log file creation for error's and exception occurred in the App.

This app is going to be used by users with limited access rights on the windows system.
So I want to make sure that the log file get created in a location where Users cannot write to it or delete it and I do not want get an Unauthorized Access Exception or to say error while creating the log file.

In short which place in the Windows system is the best suitable place to create a log file for each user who uses this app of mine.

Please advise.

Thanks in advance.

解决方案

Simple. Use the windows event log

here's an article on how to use it

How To Create a Windows Event Log and Write your Custom Message as well[^]

Does that suit your needs?


这篇关于用C#创建日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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