Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Event Log Madness - Changing the log associated with a log

Event Log Madness - Changing the log associated with a log

Scheduled Pinned Locked Moved C#
visual-studiocomwindows-adminquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prod pt
    wrote on last edited by
    #1

    Hi, I have created an entry in a custom event log:

    if (!EventLog.SourceExists("TestSource"))
    EventLog.CreateEventSource("TestSource", "System");
    EventLog evtLog = new EventLog();
    evtLog.Source = "TestSource";
    evtLog.WriteEntry("This is a test", EventLogEntryType.Information);

    I now decide to use my own custom log so I change "System" to "TestLog". This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"

    if (EventLog.SourceExists("TestSource"))
    EventLog.DeleteEventSource("TestSource");

    If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log. This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell: http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^] What's going on? It seems that once a source is associated with a log there's no way of removing that association.

    C 1 Reply Last reply
    0
    • P prod pt

      Hi, I have created an entry in a custom event log:

      if (!EventLog.SourceExists("TestSource"))
      EventLog.CreateEventSource("TestSource", "System");
      EventLog evtLog = new EventLog();
      evtLog.Source = "TestSource";
      evtLog.WriteEntry("This is a test", EventLogEntryType.Information);

      I now decide to use my own custom log so I change "System" to "TestLog". This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"

      if (EventLog.SourceExists("TestSource"))
      EventLog.DeleteEventSource("TestSource");

      If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log. This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell: http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^] What's going on? It seems that once a source is associated with a log there's no way of removing that association.

      C Offline
      C Offline
      Chintan Desai
      wrote on last edited by
      #2

      Restart your machine...Hope it will work.

      Thanks, Chintan(India)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups