Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Write Entry to Event Log

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-26 : 20:26:57
Hi, I tried to write entry to event log, but I found that in the DB Maintenance log I created, there are also lots of events from other sources (eg. MSSQLSERVER, Userenv, SceCli...), how do I create only the log for my application?


If Not objEventLog.SourceExists(AppName) Then
objEventLog.CreateEventSource(AppName, LogName)
'AppName = DB Maintenance Service
'LogName = DB Maintenance
End If
objEventLog.Source = AppName

objEventLog.WriteEntry(Entry, EventType)
'Entry = message to write



jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-02-26 : 20:39:10
http://www.google.com/search?q=.net+create+new+event+log

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-26 : 21:42:58
the link just shows the way to create a log and write entry into it. I can create the log and also writting message into it, but the log also have other messages from other sources...Please advise.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-02-26 : 21:56:40
The very first result returned explains how to create a new custom event log!

quote:

You can use the EventLog class to create a custom event log on a local or remote computer. You might create a custom log if you wanted to organize your entries in a more granular way than is allowed when your components write entries to the default Application log.



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-27 : 20:19:27
It is strange that when I tried to create some new log, some can be created, some cannot....

eg.

'AppName = DB Maintenance Service
'LogName = DB Maintenance Log
'no log created

'AppName = DB Maintenance Service
'LogName = My Log
' log created successfully...
Go to Top of Page
   

- Advertisement -