本文介绍了Windows服务 - 事件日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在构建一个将部署在Windows上的Windows服务 server 2003我希望将活动写入事件日志,我想要b $ b想要它自己的日志叫(''CustomLog'') 以下是我到目前为止...它的构建很好但是当我开始时 服务我收到以下错误。 --------------------------- 服务 --------------------------- CWindowService本地计算机上的服务启动然后停止。 如果没有工作要做,有些服务会自动停止,例如,性能日志和警报服务。 > --------------------------- OK - -------------------------- 我做错了什么?在这段代码之后我就有了这一行....而且 从来没有问题。 EventLog.WriteEntry(刷新成功启动。); // 1。创建源,如果它尚不存在。 if(!EventLog.SourceExists(" CustomLog")) { EventLog .CreateEventSource(" CustomLog"," MyNewLog"); } // 2。创建一个EventLog实例并分配其源。 EventLog myLog = new EventLog(); myLog.Source =" CustomLog"; // 3。在事件日志中写入一个信息性条目。 myLog.WriteEntry(写入事件日志。); I am building an windows service that is to be deployed on a windowsserver 2003 and I want to have activity written to the event log, Iwant its own log called (''CustomLog'') Below is what I have so far...its builds fine but when I go to startthe service i get the following error. ---------------------------Services---------------------------The CWindowService service on Local Computer started and then stopped.Some services stop automatically if they have no work to do, forexample, the Performance Logs and Alerts service.---------------------------OK---------------------------What am I doing wrong? Right after this code I have this line....and itnever had an issue.EventLog.WriteEntry("Refresh started successfully."); //1. Create the source, if it does not already exist.if (!EventLog.SourceExists("CustomLog")){EventLog.CreateEventSource("CustomLog", "MyNewLog");}//2. Create an EventLog instance and assign its source.EventLog myLog = new EventLog();myLog.Source = "CustomLog";//3. Write an informational entry to the event log.myLog.WriteEntry("Writing to event log."); 推荐答案 这篇关于Windows服务 - 事件日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 18:07