SQL server

Logging with xp_logevent.

xp_logevent is used to log messages to the SQL error log. A stored procedure can be created to do a task and log its finish time (or different  waypoints) to the SQL error log. This comes in handy during trouble shooting, or if any activity has to be monitored from the already present SQL error log. I like using xp_logevent as no special reading/writing program has to be created, and the logs can be read across the network from other windows programs/WMI/Log readers. Audit triggers can also use this procedure to record info in the SQL error logs. An example of usage is:

xp_logevent 50001,’Testing xp_logevent by stan’,informational

The error number (50001 in my case), can be any number greater than 50,000 and less than 2147483647


Thinking about someting? Leave a Reply...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s