|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating a custom logI'm using the following code: Dim lsEventSource As String = "test1234" Dim lsEventLog As String = "CustomLog" If (Not EventLog.SourceExists(lsEventSource)) Then EventLog.DeleteEventSource(lsEventSource) EventLog.CreateEventSource(lsEventSource, lsEventLog) End If Dim llogEventLog As EventLog llogEventLog = New EventLog llogEventLog.Source = lsEventSource llogEventLog.WriteEntry("This is a test spot for the event log.") Can anybody tell me what's wrong with the code? No matter what I put for the lsEventLog name, it always is being written to the Application log. I've also tried changing the name of the EventSource to something else just to see what happens then..... April 15, 2005
The problem is when you create the new event log llogeventlog, you are not specifying the name of the log... Dim lsEventSource As String = "test1234" Dim lsEventLog As String = "CustomLog" If (Not EventLog.SourceExists(lsEventSource)) Then EventLog.DeleteEventSource(lsEventSource) EventLog.CreateEventSource(lsEventSource, lsEventLog) End If Dim llogEventLog As EventLog llogEventLog = New EventLog llogEventLog.Source = lsEventSource llogEventLog.Log = lsEventLog ' Add custom log name llogEventLog.WriteEntry("This is a test spot for the event log.") This will specify the custom log as the one to write to. Have a great day! Joseph Bittman MCAD Microsoft Certified Application Developer Show quoteHide quote "UJ" <U*@nowhere.com> wrote in message news:eAYTrGeQFHA.3868@TK2MSFTNGP10.phx.gbl... >I am trying to have a service write out to a custom log in the event log. >I'm using the following code: > > > Dim lsEventSource As String = "test1234" > Dim lsEventLog As String = "CustomLog" > > If (Not EventLog.SourceExists(lsEventSource)) Then > EventLog.DeleteEventSource(lsEventSource) > EventLog.CreateEventSource(lsEventSource, lsEventLog) > End If > > Dim llogEventLog As EventLog > llogEventLog = New EventLog > llogEventLog.Source = lsEventSource > > llogEventLog.WriteEntry("This is a test spot for the event log.") > > > Can anybody tell me what's wrong with the code? No matter what I put for > the lsEventLog name, it always is being written to the Application log. > I've also tried changing the name of the EventSource to something else > just to see what happens then..... > > >
Why use a module instead of class?
An absence of IntelliSense in this situation Making trial version 2d array question... Question about Namespaces and the Object Browser. Hierarchal recordset Installing VS.NET 2005 Beta 1 disable items in CheckBoxList transparancy in vb.net Populating WinForms DataGrid |
|||||||||||||||||||||||