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.
In my experience, the most common problem in writing to event logs is that the user does not have sufficient permission to write to the event log. Can you check the identity that the Windows service is running under, and verify that it has permission to write to the event log that you have created?
And, can you check the event log to see if any errors are being recorded when attempts are made to write to it?
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.
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:
How to setup event log security programmatically using the .Net Framework
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);
HTH
Kev
If you want to use logging instead of debugging don't use the event log. Use plain old text logs.