write to application event viewer

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.
 
G

Guest

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
 
D

david.boyle

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
 
C

chanmm

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Event Properties using C# 1
write to application Event Viewer 2
Dotnet 4 - Writing to event log 2
DBCC TRACEON 1
EventID and EventSource Problems 2
event ID 0 1
Logging NT Events 3
Problem with Custom Event Logs 1

Top