write to application event viewer

  • Thread starter Thread starter sk.rasheedfarhan
  • Start date Start date
S

sk.rasheedfarhan

Hi all,

According to my project requirement I have to write the NT Event
information of SQL Server into EventLog viewer.


For more clear I want to write the following information into
Application log file:
---------------------------------------------------------------------------­---------------------------



Event ID :17055
Source :MSSQLServer
Date : xx-xx-xx
Time :xx-xx-xx
User :xxxxxx
Category :xxx
Computer :xxxx
Type :Information
Description:
17148 :
SQL Server is terminating due to 'stop' request from Service Control
Manager.
---------------------------------------------------------------------------­---------------------------



Through code I have to enter the above information into Application
Event Log. So I am able to write any event from "EventLog class"
through C#. But the event generated is not having the proper
description. It is having the following description:
[General one not specific to any eventid and source]
Source : Application
EventID : 0
Description :
The description for Event ID ( 0 ) in Source ( Application ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: Writing to
event log.
My Major Problem:
If I given EventID = 17055 and Source = MSSQLSERVER so how can I write
the above log information in the Event Log.And also, is it possible to

retrieve the description of the NT event from the EventMessageDLL?


Let me know ASAP.
Hope someone can help.
Sincerely
Rasheed.
 
You need to register your event source first:
sEvtSource = "MyAppl";
if (!EventLog.SourceExists(sEvtSource))
EventLog.CreateEventSource(sEvtSource,sEvtLog);
EventLog.WriteEntry(sEvtSource,"A test
event",EventLogEntryType.Information,2001);

Hope this helps
 
My Major Problem:
If I given EventID = 17055 and Source = MSSQLSERVER so how can I write
the above log information in the Event Log.And also, is it possible to

retrieve the description of the NT event from the EventMessageDLL?
<snip>

I might be misunderstanding your intent, but it sounds very much like
you want to write a "SQL Server stopped" event to the event log with a
source value of MSSQLSERVER. This is a *very* bad idea for the
following reasons:

1) This information is already logged by SQL Server.
2) Your app would effectively be masquerading as SQL Server.

Cheers,

Dave Boyle
 
Take a look:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.eventlog(d=ide).aspx

chanmm

Hi all,

According to my project requirement I have to write the NT Event
information of SQL Server into EventLog viewer.


For more clear I want to write the following information into
Application log file:
---------------------------------------------------------------------------­---------------------------



Event ID :17055
Source :MSSQLServer
Date : xx-xx-xx
Time :xx-xx-xx
User :xxxxxx
Category :xxx
Computer :xxxx
Type :Information
Description:
17148 :
SQL Server is terminating due to 'stop' request from Service Control
Manager.
---------------------------------------------------------------------------­---------------------------



Through code I have to enter the above information into Application
Event Log. So I am able to write any event from "EventLog class"
through C#. But the event generated is not having the proper
description. It is having the following description:
[General one not specific to any eventid and source]
Source : Application
EventID : 0
Description :
The description for Event ID ( 0 ) in Source ( Application ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: Writing to
event log.
My Major Problem:
If I given EventID = 17055 and Source = MSSQLSERVER so how can I write
the above log information in the Event Log.And also, is it possible to

retrieve the description of the NT event from the EventMessageDLL?


Let me know ASAP.
Hope someone can help.
Sincerely
Rasheed.
 
Back
Top