EventLog logName and source Usage.

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default EventLog logName and source Usage.

    I think I am missing something and hopefully someone can set me straight.

    I am trying to create an event log with the logName and source arguments.
    The logName is always set to MyLog. The source is set to one of several
    names, for example: MySource1 and MySource2. I want all the messages to be
    in the MyLog folder of the Event Viewer with the source changing by the
    application writing the event entry.

    Now to create the event log entry I use either the deployment
    PojectInstaller class or the EventLog.CreateEventSource method. Both of
    these methods get the MyLog folder in the event viewer.

    For this example I will use the create method. So the create statements for
    both Applications are:

    MySource1 application:

    EventLog.CreateEventSource( “MySource1”, “MyLog”, “.” );

    MySource2 application:

    EventLog.CreateEventSource( “MySource2”, “MyLog”, “.” );

    After the appropriate programs execute these statements I see the MyLog
    folder along with the Application, Security, and System folders. Ok
    everything is as expected.

    Now I write an event entry using the MySource1 as the source. Then I write
    another event for the MySource2. I want both entries in the MyLog folder
    when I look in the event viewer.

    I use the following statements to write the event entry and I change the
    sourceName variable to either MySource1 or MySource2 depending on the
    application.

    My write code looks like:

    Using( EventLog eventLog = new EventLog( “MyLog”, “.”, sourceName )
    {
    try
    {
    eventLog.WriteEntry( “My message” );
    }
    catch( Exception ex )
    {
    :
    }
    try
    {
    eventLog.Close(); // make sure all is flushed to the log.
    }
    catch( Exception ex )
    {
    :
    }
    }

    This works as expected and entry is written, but not to the expected folder.
    The problem is if I write the MySource1 followed by the MySource2 I see the
    MySource1 in the MyLog folder, but the MySource2 is in the Application
    folder. The MySource2 always seems to go to the Application folder. What is
    going on? If the logName is MyLog the WriteEntry should only write to the
    MyLog folder.


    --
    Jim
    JimM Guest

  2. Similar Questions and Discussions

    1. Eventlog problems
      Hi All, I'm writing an webservice and want to log errors etc. and thoughed the Eventlog would be a nice place for it. The problem is that i can't...
    2. SecurityException on EventLog.CreateEventSource
      Hi All, Can anybody tell me how to write to the application event log with a new source. I'm running the .Net example code but can't get it to...
    3. EventLog access through ASP.Net app
      I have an ASP.Net app for which I want to be able to log events to the Windows 2000 server event log under a special log name. I encountered the...
    4. [ANN] win32-eventlog 0.1.0
      Hi all, I'm happy to announce the first release of win32-eventlog. This is a Ruby interface to the Win32 EventLog. Synopsis ========...
    5. Trouble writing to EventLog
      My aspx page can not write to the EventLog "Requested registry access is not allowed". I have read the posts about ASPNET not having access to...
  3. #2

    Default RE: EventLog logName and source Usage.

    Hi Jim,

    We have reviewed this issue and are currently researching on it. We will
    update you ASAP. Thanks for your patience!

    Kevin Yu
    =======
    "This posting is provided "AS IS" with no warranties, and confers no
    rights."

    Kevin Yu [MSFT] Guest

  4. #3

    Default RE: EventLog logName and source Usage.

    Hello Jim,

    I test following code on my PC, but get correct results:

    EventLog.CreateEventSource("MySource1","MyLog","." );
    EventLog.CreateEventSource("MySource2","MyLog","." );

    EventLog eventLog1 = new EventLog( "MyLog",".","MySource1" );
    EventLog eventLog2 = new EventLog( "MyLog",".","MySource2" );

    eventLog1.WriteEntry("log1");
    eventLog2.WriteEntry("log2")

    Is it possible that the "sourceName" was set to incorrect value in your
    real application? You may add its value also in the logged message to check
    this.

    Luke

    [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139