May 5, 2008

How to log Events from ASP

How to write Events to eventlog by ASP

 

Open run command à Type notepad

Open notepad à Type/Copy/Paste the code below into the notepad and save as Test.asp.

 

<%@ Language=VBScript %>

<HTML>

<BODY>

<% 'Use these Constants to designate the type of Event Log.

const SUCCESS = 0

const ERROR = 1

const WARNING = 2

const INFORMATION = 4

const AUDIT_SUCCESS = 8

const AUDIT_FAILURE = 16

dim WshShell set WshShell = Server.CreateObject("WScript.Shell")

wshshell.Logevent WARNING, " Event Logged Successfully by Windows Script Host!"

set wshshell=nothing

Response.write "Event Logged Successfully by Windows Script Host!" %>

</BODY>

</HTML>

 

Now copy the test.asp and place into C:\Inetpub\wwwroot à hit the browser as http://localhost/test.asp

OR

create a folder name Test and put this test.asp into this folder. Right click on Test folder à Click Web Sharing Tab à Share This Folder àKeep Name as Test à Apply OK. à Now hit http://localhost/test/test.asp

 

Now open run command à Type eventvwr à See application events à You will get logged your events to EventLog

Enjoy J

Ref: For more information visit http://support.microsoft.com/kb/301309

No comments:

Post a Comment

SQL - Difference between CAST,CONVERT and PARSE

TODO---