我的自定义Windows服务未写入我的自定义事件日志

编程入门 行业动态 更新时间:2024-10-27 12:37:08
本文介绍了我的自定义Windows服务未写入我的自定义事件日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经编写了一个自定义Windows服务,该服务将数据写入自定义事件日志(在Windows事件查看器中).

I have written a custom Windows Service that writes data to a custom Event Log (in the Windows Event Viewer).

为了开发服务使用的业务逻辑,我创建了一个Windows窗体,该窗体模拟Windows Service的Start/Stop方法.

For dev'ing the biz logic that the service uses, I created a Windows Form which simulates the Start/Stop methods of the Windows Service.

通过Windows窗体执行biz逻辑时,信息已成功写入我的自定义事件日志.但是,当我从自定义Windows服务运行相同的biz逻辑时,信息无法写入事件日志.

When executing the biz logic via the Windows Forms, info is successfully written to my custom Event Log. However, when I run the same biz logic from the custom Windows Service, information is failing to be written to the Event Log.

为清楚起见,我编写了一个库(.dll),该库可以完成我希望我的自定义服务执行的所有工作-包括创建/写入自定义事件日志.我的Form应用程序像Windows服务一样引用了该库.

To be clear, I have written a library (.dll) that does all the work that I want my custom service to do - including the create/write to the custom Event Log. My Form application references this library as does my Windows Service.

认为问题是安全性问题,我将自定义Windows服务手动设置为管理员"身份设置为登录",但是该服务仍未写入事件日志.

Thinking the problem is a security issue, I manually set the custom Windows Service to "Log on" as "Administrator", but the service still did not write to the Event Log.

我坚持如何解决此问题,因为在运行服务时无法调试并进入代码(如果有调试服务的方法,请共享).

I'm stuck on how to even troubleshoot this problem since I can't debug and step into the code when I run the service (if there is a way to debug a service, please share).

您是否对导致我的服务无法写入事件日志的原因有任何想法?

Do you have any ideas as to what could be causing my service to fail to write to the event log?

推荐答案

我发现了为什么我的服务没有写入事件日志的原因.

I discovered why my service wasn't writing to the Event Log.

该问题与试图写入EL的代码/安全性/等等的任何部分均无关.问题是我的服务没有成功收集写入EL的信息-因此,该服务甚至没有尝试写入日志.

The problem had nothing to do with any part of the code/security/etc that was attempting to write to the EL. The problem was that my service wasn't successfully collecting the information that is written to the EL - therefore, the service wasn't even attempting to write the log.

现在,我修复了收集数据的代码,数据已成功写入事件日志.

Now that I fixed the code that collects the data, data is successfully writing to the event log.

由于该问题与真正的问题无关,我愿意关闭该问题.

I'm open to having this question closed since the question was amiss to the real problem.

更多推荐

我的自定义Windows服务未写入我的自定义事件日志

本文发布于:2023-11-05 21:25:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561900.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   事件   日志   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!