Groups | Blog | Home
all groups > asp.net > july 2007 >

asp.net : EventViewer using


pelegk1
7/27/2007 11:50:01 PM
i have 2 questions :
1)i tried to use this code :
Public Sub Write2EventViewer(ByVal errorMessage As String)

Dim strSource As String = "MyWebSite" 'name of the source
Dim strLogType As String = "Application" 'type of the log 'Application
Dim strMachine As String = "." ' //machine name


If EventLog.SourceExists(strSource, strMachine) = False Then

System.Diagnostics.EventLog.CreateEventSource(strSource,
strLogType)

End If
Dim MyLog As New EventLog(strLogType, ".", strSource)

MyLog.WriteEntry(errorMessage, EventLogEntryType.Warning)
End Sub

in the begining i assume i did some mistake and now the error instead of
appearing under Application ,with source=MyWebSite
i have a new log EVENT under application which called MyWebSite
and the error are written to there.
how can i fix this so it will appear under application?
2)how can i create a dll from this code and use it in my asp.net web site
project?

thnaks in advnace
peleg

Manish Bafna
7/28/2007 1:08:10 AM
Hi,
Why create dll?.Instead you can create a public class which encapsulates
your log.Below link shows how to create public class which encapsualates your
logic and which you can use anywhere in the project:
http://www.dotnetspider.com/code/C-240-Write-Event-Log.aspx
--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



[quoted text, click to view]
AddThis Social Bookmark Button