Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:17:57+00:00 2026-05-24T17:17:57+00:00

I am writing a simple service and logging exceptions and other notable items to

  • 0

I am writing a simple service and logging exceptions and other notable items to the EventLog. Below is the code for the service. Somehow, although I can see the “FDaemon” log, I don’t see any events in it. My started and stopped events are nowhere in the log; the log lists 0 events.

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;

namespace FDaemon
{
    public class EmailDigester : ServiceBase, IDebuggableService
    {
        private Timer digestTimer;
        private EmailDigesterWorker worker;
        private EventLog eventLog;

        public EmailDigester()
        {
            // fire up the event log
            this.eventLog = new System.Diagnostics.EventLog();

            ((ISupportInitialize)(this.eventLog)).BeginInit();

            this.eventLog.Source = "EmailDigester";
            this.eventLog.Log = "FDaemon";
            if (!EventLog.SourceExists(this.eventLog.Source))
            {
                EventLog.CreateEventSource(this.eventLog.Source, this.eventLog.Log);
            }

            this.AutoLog = false;
            this.ServiceName = this.eventLog.Source;

            ((ISupportInitialize)(this.eventLog)).EndInit();
        }

        public void DebugStart(string[] args)
        {
            this.OnStart(args);
        }

        protected override void OnStart(string[] args)
        {
            this.worker = new EmailDigesterWorker(1, eventLog);

            // no need to multithread, so use a simple Timer
            // note: do not take more time in the callback delegate than the repetition interval
            if (worker.RunTime.HasValue)
            {
                worker.ServiceStarted = true;
                TimerCallback work = new TimerCallback(this.worker.ExecuteTask);

                TimeSpan daily = new TimeSpan(24, 0, 0);  // repeat every 24 hrs
                TimeSpan startIn; // how much time till we start timer  
                if (worker.RunTime <= DateTime.Now)
                    startIn = (worker.RunTime.Value.AddDays(1.00) - DateTime.Now); // runTime is earlier than now. we missed, so add a day to runTime
                else
                    startIn = (worker.RunTime.Value - DateTime.Now);

                this.digestTimer = new Timer(work, null, startIn, daily);
            }

            eventLog.WriteEntry("EmailDigester started.", EventLogEntryType.Information);
        }

        public void DebugStop()
        {
            this.OnStop();
        }

        protected override void OnStop()
        {
            worker.ServiceStarted = false; 
            if (this.digestTimer != null)
            {
                this.digestTimer.Dispose();
            }

            eventLog.WriteEntry("EmailDigester stopped.", EventLogEntryType.Information);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:17:57+00:00Added an answer on May 24, 2026 at 5:17 pm

    First: I am assuming that you’ve stepped through and the WriteEntry() function does, in fact, execute.

    If your source "EmailDigester" is registered with any other EventLogs (e.g. Application, Security, etc.), then the messages will appear in that EventLog no matter what you do. In fact, I believe only the first 8 characters of a source are considered.

    You can check this by going to the registry @:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\ and checking each log’s sources.

    You might also considering changing your source to a random value (that you know won’t be registered) and seeing if your logs show up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple logging service in DynamoDB. I have a logs table that
I'm writing a very simple web service, written in Python and run as CGI
I'm looking into writing simple graphics code in Android and I've noticed some synchronized()
I'm writing a simple Google Web Toolkit service which acts as a proxy, which
I'm writing a simple movie database which has a three tier stack of service
I am writing an app that’s a very simple web service client. I have
One can use poll/select when writing a server that can service multiple clients all
I am writing a simple proof-of-concept web service using ASP.NET MVC3 controller with JSON
I am writing a relatively small and simple Windows Service, and using Moles to
I'm writing a simple music player, and I've created a playback service which implements

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.