?
Solved

Writing Windows Service1 Event Log?

Posted on 2006-06-30
1
Medium Priority
?
378 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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