本文介绍了Windows服务正在运行,但事件日志不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个Windows服务,正在侦听队列中的消息,但未从队列中读取消息.我创建了一个事件日志来检查服务启动和关闭期间的日志,但未写入日志.我不想调试服务,因为这是一个痛苦的过程.有没有解决此问题的方法.消息需要由服务读取并写入数据库.

I have a windows service listening to messages from a queue but the messages are not read from the queue.I created an event log to check for logs during service startup and shutdown but the logs are not written. I do not want to debug the service since it is a painful process.Is there a way to solve this issue.The messages need to be read by the service and written to a database.

推荐答案

这听起来好像Windows服务所运行的帐户没有足够的权限来写入相关事件日志.

This certainly sounds as if the account that your windows service is running under doesn't have enough rights to write to the event log in question.

为非管理员帐户设置事件日志权限可能有点荒唐,因为您需要使用SDDL等配置自定义安全描述符.但是,有一篇非常方便的MS知识库文章,介绍如何以编程方式执行此操作:

Setting event log permissions for non-admin accounts can be a bit of a black art because you need to configure custom security descriptors using SDDL etc. However there's a very handy MS knowledgebase article on how to do this programmatically:

我现在一直在使用它,它很简单:

I use this all the time now and it's as simple as:

int mask = EventLogSecurity.CustomSD_ALL_ACCESS;

string logName = "Application";
string domain = "MyMachineOrDomainName";
string account = "UserAccount";

EventLogSecurity.AddUserToEventLogCustomSD(logName, domain, account, mask);

这篇关于Windows服务正在运行,但事件日志不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:27