Solved

Writing Windows Service1 Event Log?

Posted on 2006-06-30
1
360 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now