应用日志写作 [英] Application Log Writing

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

问题描述





我正在尝试写入应用程序事件日志。此代码将在无人参与的服务器上执行,因此这是编写它的最佳位置。我一直收到安全错误,试图读取安全日志以查看我的日志名称是否存在。我错过了什么,但我似乎无法弄清楚是什么。我已尝试使用和不使用appLog.Log =应用程序;



这是我的代码....



谢谢,

Glenn



Hi,

I'm trying to write to the application event log. This code will be executing on an unattended server so this is the best place to write it. I keep receiving a "Security" error trying to read the security log to see if my logname exists. I'm missing something, but I can't seem to figure out what. I've tried with and without the appLog.Log = "Application";

Here's my code....

Thank you,
Glenn

status = string.Format("{0} - {1}, {2},\n CreateDB (Create 'Server' table) 
                       returned:  {3}, \n{4}",
                        DateTime.Now,
                        System.AppDomain.CurrentDomain.FriendlyName,
                        System.Environment.MachineName,
                        ex1.Message,
                        ex1.StackTrace);

System.Diagnostics.EventLog appLog = new System.Diagnostics.EventLog();
appLog.Source = CommonClass.Product;
appLog.Log = "Application";
appLog.WriteEntry(status);
return (status); 

推荐答案

这不是它的工作原理。目前还不是很清楚你想要实现什么,但可能你正在尝试登录特定于应用程序的目录。在这里,我将解释如何实现这一目标:如何创建活动记录文件夹 [ ^ ]。



-SA
This is not how it works. It's not quite clear what you are trying to achieve, but probably you are trying to log in the application-specific directory. Here I explain how to achieve that: How to create event log under a folder[^].

—SA


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

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