EventLog.EntryWritten firing for events in the past

Hello - I have a windows service that will setup a delegate for the EntryWritten event. My understanding of this event handler is that it will only fire when an entry is written to the event log. However, events from the past that are contained in that eventlog
(I'm talking events that occurred in some cases 2 years ago) that were previously written also cause the delegate to fire. For example today, 4/8/2015, I see events that occurred back in 2013 acting as though they were written today.
Is this behavior expected? It seems as thought it is a bug or possibly something I am not doing correctly in the code. Any light that can be shed on this situation would be great.
private static bool SetupListeners()
var logsConfigurationSection = ConfigurationManager.GetSection("LogsSection") as LogsConfigurationSection;
if (logsConfigurationSection == null) return false;
for (var incr = 0; incr < logsConfigurationSection.Logs.Count; incr++)
List<EventLog> el;
if (logsConfigurationSection.Logs[incr].Wildcard)
el = EventLog.GetEventLogs()
.Where(w => w.Log.ToLower().StartsWith(logsConfigurationSection.Logs[incr].Name.ToLower())).ToList();
else
el = EventLog.GetEventLogs()
.Where(w => w.Log.ToLower().Equals(logsConfigurationSection.Logs[incr].Name.ToLower())).ToList();
foreach (var eLog in el)
Log.Information("Setting up EntryWritten listener for {0}. Configuration is name {1} and wildcard {2}",
eLog.Log, logsConfigurationSection.Logs[incr].Name, logsConfigurationSection.Logs[incr].Wildcard);
eLog.EntryWritten += OnEntryWritten;
eLog.EnableRaisingEvents = true;
ListeningLogs.Add(eLog);
return true;
EDIT 1: This is C# 5.0, .NET Framework 4.5 and the service runs on Windows Server 2008 and/or Windows Server 2012 (core and full).
EDIT 2: Looks like this situation has been present for some time given this post on SO:
http://stackoverflow.com/questions/19137560/eventlog-entrywritten-event-handles-events-from-the-past
As a stopgap in the code, I plan to interrogate EventLogEntry.TimeWritten (converted to UTC) relative to DateTime.UtcNow with a "buffer" of 2 minutes. This is inside of OnEntryWritten (the delegate called):
if (elEntry.TimeWritten.ToUniversalTime() < DateTime.UtcNow.AddMinutes(-_bufferMins))
return;
Regards,
Ryan

Hello Ryan,
I created a small demo which could make the scenario: the event mesage could be delayed:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace P20150409
class Program
static void Main(string[] args)
EventLog myNewLog = new EventLog("Application", ".", "dotNET Sample App");
myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
myNewLog.EnableRaisingEvents = true;
while (true)
System.Threading.Thread.Sleep(3000);
string EventWriteTime = DateTime.Now.ToString();
Console.WriteLine("Log is written at" + EventWriteTime);
myNewLog.WriteEntry("Test message written at" + EventWriteTime + " " + System.Threading.Thread.CurrentThread.ManagedThreadId, EventLogEntryType.Information);
Console.WriteLine();
Console.ReadLine();
private static void MyOnEntryWritten(object sender, EntryWrittenEventArgs e)
System.Threading.Thread.Sleep(6000);
Console.WriteLine("EntryWritten event is fired at" + DateTime.Now.ToString());
Console.WriteLine("Log time is" + e.Entry.Message);
Console.WriteLine();
This is the result:
As we can see that the interval between event fired time and the current written time is bigger and bigger, so it could be that an event is fired 2 year later...And for reason, we can see that it is becuase i set the event sleep 6s whenever it
is fired. So i am wondering in your event, there is a similar feature which causes this delay.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Search for events in the past

    Is there a way to search for events in the past? If not, is there another calendar application with this feature that would be able to sync with my iPod Touch? This feature is one that I must have. I apologize if I come off as whining but my Palm calendar/address book was able to do this.
    Thx

    Hi helenhopelouise,
    Welcome to the Support Communities!
    The search feature within the Calendar app should show all events, past and present.   First, check to see if you are syncing All Events in your Calendar app.  Tap on the Settings app on your Home Screen.  Then choose Mail, Contacts Calendars.  Scroll down to the Calendar section to see your options.
    Next, try the "Spotlight Search" of all of the data on your iPhone to see if the calendar event you are looking for appears. 
    Finally, try quitting all of your open apps and restarting and/or resetting your iPhone.
    iOS: Understanding Spotlight Search
    http://support.apple.com/kb/ht3636
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/HT1430
    Cheers,
      - Judy

  • Calendar-notifications for events in the past

    Since iOS 7, my notifications for an calendar-event in the notification center are gone, if i'm checking them to late. Is it possible to change the settings, so I can see them, until I'm going to delete them?
    If not, is there an alternative calendar-app with push notifications I can use instead?
    Thanks for an answer.

    Hello Ryan,
    I created a small demo which could make the scenario: the event mesage could be delayed:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    namespace P20150409
    class Program
    static void Main(string[] args)
    EventLog myNewLog = new EventLog("Application", ".", "dotNET Sample App");
    myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
    myNewLog.EnableRaisingEvents = true;
    while (true)
    System.Threading.Thread.Sleep(3000);
    string EventWriteTime = DateTime.Now.ToString();
    Console.WriteLine("Log is written at" + EventWriteTime);
    myNewLog.WriteEntry("Test message written at" + EventWriteTime + " " + System.Threading.Thread.CurrentThread.ManagedThreadId, EventLogEntryType.Information);
    Console.WriteLine();
    Console.ReadLine();
    private static void MyOnEntryWritten(object sender, EntryWrittenEventArgs e)
    System.Threading.Thread.Sleep(6000);
    Console.WriteLine("EntryWritten event is fired at" + DateTime.Now.ToString());
    Console.WriteLine("Log time is" + e.Entry.Message);
    Console.WriteLine();
    This is the result:
    As we can see that the interval between event fired time and the current written time is bigger and bigger, so it could be that an event is fired 2 year later...And for reason, we can see that it is becuase i set the event sleep 6s whenever it
    is fired. So i am wondering in your event, there is a similar feature which causes this delay.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Notifications for events in the past

    Since iOS 7, my notifications in the notification center are gone, if i'm checking them to late. Is it possible to change the settings, so I can see them, until I'm going to delete them?
    If not, is there an alternative callendar-app with push notifications I can use instead?
    Thanks for an answer.
    DerKomahnda

    Hello Ryan,
    I created a small demo which could make the scenario: the event mesage could be delayed:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    namespace P20150409
    class Program
    static void Main(string[] args)
    EventLog myNewLog = new EventLog("Application", ".", "dotNET Sample App");
    myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
    myNewLog.EnableRaisingEvents = true;
    while (true)
    System.Threading.Thread.Sleep(3000);
    string EventWriteTime = DateTime.Now.ToString();
    Console.WriteLine("Log is written at" + EventWriteTime);
    myNewLog.WriteEntry("Test message written at" + EventWriteTime + " " + System.Threading.Thread.CurrentThread.ManagedThreadId, EventLogEntryType.Information);
    Console.WriteLine();
    Console.ReadLine();
    private static void MyOnEntryWritten(object sender, EntryWrittenEventArgs e)
    System.Threading.Thread.Sleep(6000);
    Console.WriteLine("EntryWritten event is fired at" + DateTime.Now.ToString());
    Console.WriteLine("Log time is" + e.Entry.Message);
    Console.WriteLine();
    This is the result:
    As we can see that the interval between event fired time and the current written time is bigger and bigger, so it could be that an event is fired 2 year later...And for reason, we can see that it is becuase i set the event sleep 6s whenever it
    is fired. So i am wondering in your event, there is a similar feature which causes this delay.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • My iphone has calendar history for 10 years.  my icloud only shows about 6-8 weeks back.  how can i get icloud to show all the calendar events in the past that are on iphone?

    my iphone has calendar history for 10 years.  my icloud only shows about 6-8 weeks back.  how can i get icloud to show all the calendar events in the past that are on iphone?

    I encountered a similar problem when finally (and with much regret) I was obliged to migrate my MobileMe to iCloud last month.
    Many years of iCal history vanished without trace during this automated transition by Apple and iCloud then kindly synched the resulting vacuum back to iCal on my Mac.
    Fortunately, iCloud wasn’t able to decimate iCal on my other Macs because (1) they are still running Snow and (2) I had switched them off as a precaution.  Good job I did.
    My solution was to export my iCal data on one of those other Macs to a backup file – then I imported that backup file into my Lion-updated Mac’s iCal. That restored all the iCloud-deleted iCal data back on to my Mac and this was promptly synched automatically to my Calendar on iCloud.  So now it’s all there and showing.
    Perhaps you could do something similar?  In the meantime, be very careful not to let iCloud’s amnesia get synched to your iPhone (and other devices).
    Experience has taught me never to trust an “upgrade” until it is proven to be working correctly and always to keep in reserve another Mac with a properly-functioning system and all synching to it switched off...

  • Multiple events in the past?

    I am a recent convert from windows to mac so be gentle with me! I want to record events of the past so I can use them on my ipod touch to jog my failed memory ( result of a stroke!) Is this the application to use? I have typed in the dates but there is not a year view to bring them all up and get a summary view - any ideas?Most of the events I want to "remember" are from the past of course. Can anyone suggest a way to do this or an alternative option? typically there are about 6 events a year and the years are 20 years ago.
    many thanks in advance.
    Brian

    Someone told me this ~ "There is a reported bug that if you delete a photo then merge or otherwise organize events prior to emptying the iPhoto trash that the master is not deleted" ~ that is what I do every time I organize things so I am wondering how to get rid of this bug or repair it and how to clean up my files to reflect what I want.
    Yes there is such a bug.  You can recover your "missing" masters and delete them but it will cost your your projects, i.e. books, calendars, slideshows, etc.  The best solution would be to restore a backup copy  of the library before the deletion and joining of events occurred.  However, it would not have your newer photos.
    Here's how to find and cull out those masters:
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.>Click on the Add Library button,
    2 -  select the library you want to add from those in the selection window.
    3 - make sure that in the rebuild window the checkbox  "Scavange orphaned photos" is checked.
    4 - now that the library is listed in the left hand pane of iPLM, click on your library and go to the Library ➙ Rebuild Library menu option
    5 - in the next  window name the new library and select the location you want it to be placed. Click on the Create button.
    Note 1: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments. However, books, calendars, cards and slideshows will be lost.
    Note 2:  Your current library will be left untouched for further attempts at a fix if so desired.
    This will give you a new library with the missing masters grouped in an Album titled Scavenged Photos
    from which you can delete them correctly.

  • Events in the past week - REST API

    Hi, 
    How do I pull the data which gets displayed in the "Events in the Past Week" blade on Azure Preview Portal using REST APIs ?
    Thanks
    Vibhuti 

    Thanks Alex for your reply. I did look into the service management rest api. 
    I was looking for the following - 
    1. I assigned a particular role to a AZure resource group and was looking into the Azure Resource Manager REST API.  However, I did not find any REST API reference which can provide me with the events like when was the role assignment object created,
    when was it assigned to the Azure resource group etc. 
    Thanks
    Vibhuti 

  • Firefox will not access the internet. I have used Firefox for years and the past week I have not been able to get on the internet??? What is the problem. My interent works as I get email and can iuse Internet Explorer to access.

    Firefox will not access the internet. I have used Firefox for years and the past week I have not been able to get on the internet??? What is the problem. My interent works as I get email and can iuse Internet Explorer to access

    Which version of Firefox are you using?
    See
    * https://support.mozilla.com/en-US/kb/Firefox%20cannot%20load%20websites%20but%20other%20programs%20can

  • I pre order Iphone 6 this morning. Why was I charged a $30 upgrade fee when I havent been in a contract for almost 2 years? Also will they divide the price of the device over several bills like they have for me in the past?

    I pre order Iphone 6 this morning. Why was I charged a $30 upgrade fee when I havent been in a contract for almost 2 years? Also will they divide the price of the device over several bills like they have for me in the past?

        Hi there nursegrl02! We can help here with your questions regarding the upgrade fee and device charge. The upgrade fee is a one time fee that is applied when upgrading with a 2-year contract. If you pre-order with a two-year contract, you would need to add a credit card to your order as you will be charged for the device once it ships out. If you happen to purchase the iPhone with Verizon Edge, there is no upgrade fee. You will also be billed for the device in installments. You may have to pay a down payment with Edge.  Go to vzw.com/edge for more information.
    Did you upgrade with Verizon Edge or our Device payment plan in the past? If so, that is most likely why you were not charged an upgrade fee.
    Let us know if you have further questions.
    Thank you,
    LenaA_VZW
    Follow us on Twitter @VZWSupport

  • ICal - I have all the events from the past decade listed for this week

    My iCal calendar has every event from the last ten years listed in every day - each event is tagged 'repeat Every day' and 'end Never'. I have a non-corrupted version on my iPhone. I have tried restoring from Time machine and this works but then reverts to this confusion. I even deleted the .plist.
    HELP - my Calendar is my life (and my history)

    Greetings,
    Remove the following to the trash and restart your computer:
    Home > Library > Caches
    Home > Library > Calendars > Calendar Cache, Cache, Cache 1, 2, 3, etc. (Do not remove Sync Cache or Theme Cache)
    Home > Library > Preferences > com.apple.ical (There may be more than one of these. Remove them all.)
    __NOTE: Removing these files will remove any shared (CalDAV) calendars you may have access to. You will have to re-add those calendars to iCal > Preferences > Accounts.
    If the events remain:
    Reset your Sync history: http://support.apple.com/kb/TS1627
    Then restore from your backup.
    If that does not work let us know.

  • Setting the I2C Slave Wait for Event on the USB 8452

    Hi,
    I just ordered my USB 8452 and have configured my 8452 to act as Slave. Few questions arises:
    1. How can I configure my Wait for Event time to be about 210us? This is the time period for which my master device (LTC1760) write a command to the slave
    2. What other slave address can I use other than the default, 0?
    Thanks for your answers.
    Regards,
    Stan.
    Attachments:
    Block-Diagram.jpg ‏145 KB

    I have been able to solve the problem I posted early. Another thing I find as a road block is that I am only able to execute one read write from and to the master device. My master device in my project is the LCT1760 which constantly send commands to the Smart Battery which in my case is the USB-8452. My question is, how can I enable my code to run continuously for a given time and extract the commands being sent by the Master device (LCT1760) so that I can write response back to the Master?
    Any suggestion would do.
    Regards,
    Stan.

  • Can i change colors for events in the calendar?

    Can I change colors for different events in Calendars on Ipad 2?

    Philly - I always respect your opinion and what you have to say but please hear me out.
    Philly_Phan wrote:
    I see one iCal window and that makes me conclude that I have one calendar with multiple event types.
    You understand how the app works and how to create calendars. As I pointed out - I explained to one user that you have to tap the Calendar button in the upper left corner and then select the calendars that you want to view. In fact, if you have accidentally tapped Hide All Calendars - you see no events.
    I totally understand what you are saying and I rarely take an argumentative approach in this forum, but what I am trying to point out to the OP is that you cannot create different colors for "events" in one single calendar.
    For instance, if you have one calendar called "Home" and that is the one calendar that you use - if Billy has a soccer game at 6:00 PM, Jessica has band practice at 7:00 PM and you have a bridge club meeting (I'm stuck for another idea at the moment ) at 7:30 PM - and you want all of these "Events" to appear in different colors within the same calendar - it cannot be done.
    Sometimes I think this is what users want to do - differentiate the different "Events" within a single calendar - and that cannot be done - at least AFAIK.
    I didn't mean to cause confusion nor was I trying to complicate things. I just thought that I was giving a complete answer as to how the feature works.
    After all - I could have just used the "please get the iPAD user guide" line.  I just love that response.

  • I used to be able to add an event in the past on iCal, but can't now. The event immediately deletes itself. Is anyone else having this problem?

    I use my calendar to keep track of things and sometimes I like to add past events so they are on my calendar. Starting today, iCal hasn't been letting me do that and it's very frustrating!

    Hi!  I was having the same problem too- was entering an event from 2 months ago but it would then disappear.   I tried entering several events, some of them multiple times but they kept disappearing.   Finally figured it out though:  go to Settings: Mail, Contacts, Calendar.  Scroll to calendar, then You have the option of adjusting the sync time of your calendar.  Mine was set to "1 Month" so everything older than that was disappearing.   I changed it to "6 Months" and when I returned to the calendar all events I previously entered that had seemingly disappeared, magically reappeared!  Even in the multiple forms I had entered them so I deleted the duplicates!  Good Luck!

  • Enrollment of Benefits for a dependent and for date in the past

    Hello Experts-
    Can anyone let me know? What kind of changes need to be done on backend and portal for enrollment iview to enable a date in past for enrolling a dependent to the benefits..
    Thanks,
    Raj.
    Edited by: raj1234 on Feb 25, 2011 9:16 PM

    The way we have configured this as follows:
    -  We ask employees to first add all the dependents to the system before beginning their enrollment process.
    - Adjusted the Use cases for the Dependent infotype and subtypes accordingly.
    - Implemented the BADI (with custom logic for DEFAULT_DATE) HRXSS_PER_BEGDA to control the start date of the enrolled dependents.
    - We control the start date of the dependent records created in various ways (birth day of dependent, employee start date, adjustment reasons, ... )
    With this, we are able to provide employees with the ability to add dependents as of a past date and hence enroll dependents in Benefit plans as well.
    - Shanti

  • I use my tv for a monitor for my imac, the past 3 days my tv screen blacks out for a second or 2 every 30 or so seconds

    my tv blacks out every 30 seconds for about a second or 2.just started a couple days ago.I am using an imac, tried new hdmi cord and adaptor, hooked up my pc laptop via hdmi  and no problems has to be the mac
    Thanks David

    I got an EyeTV Hybrid last week, and all I can say is wow, the image quality is amazing! I hooked up my Xbox 360 and it plays with absolutely no latency, just as they said!
    So yeah, get the EyeTV!

Maybe you are looking for

  • Is there a way to export and print the browser data as a spread sheet?

    I'm in the process of logging approximately 1,500 shots for a documentary (the old fashioned way - long hand: shot #, TC in, descriptions... ) and I'm wondering if there's a way to export and print the data in the browser as a spread sheet.  It seems

  • I'm retiring an old computer and loaded Acrobat 9 Pro on a new computer.

    I entered the serial number, then was prompted for the serial number for an older version.  I have no idea what version this was updated from or the serial number.  How do I proceed with the installation?

  • Should heavy binary files be stored in database?

    I was asked an interesting question: Should a database contains all data? Or heavy binary files should be stored in file system? Example of heavy binary files : videos or heavy pdf files (+200 MB). With an old aspx web app (1.1) I tried to open a 200

  • Using jdbc with oracle-for-win95

    i am using oracle thin driver to connect my java code with oracleforwin95 i think it is called as personal oracle, while getting conection DriverManager.getConection("drivername@host:port(1521):sid","user","password") there is no sid for oracleforwin

  • Unable to find class for bean

    Hello, At times, I keep getting this error of unable to find class for bean even though, the definition I used for the Bean in the jsp page is as follows: <jsp:useBean id="deptbean" class="avt.DepartmentHandler" scope="session"/> The Error I get is "