Solved

Writing Windows Service1 Event Log?

Posted on 2006-06-30
1
374 Views
Last Modified: 2009-07-29
I've reviewed and coded many attempts of Event Log writing for a service with no success.

Here's my latest code that doesn't compile error, but doesn't write the the Windows XP "Application" log eiter.

 EventLog eventLog = new EventLog();
            eventLog.Log = "Application";
            eventLog.WriteEntry("Event Log Writing Test!", EventLogEntryType.Error);
0
Comment
Question by:kvnsdr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
cookre earned 250 total points
ID: 17022696
You left out event source info.  This works just fine:

string EvtSrc="BoxMonSvc";
string EvtLog="System";
string EvtMsg="BoxMon is still alive";
if (!EventLog.SourceExists(EvtSrc)) EventLog.CreateEventSource(EvtSrc,EvtLog);
EventLog.WriteEntry(EvtSrc,EvtMsg,EventLogEntryType.Information,42);
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question