Monday, March 5, 2007

SQL Server: How to write to the event log

Here's how to write a message to the Event Log from SQL Server:

master..xp_logevent 50001, 'Test Event', 'ERROR'

The first parameter is the Error Number and should be 50000 or above for user-defined errors. The second parameter is the actual message. And the third is the severity. It can be a text value of 'Informational' (default), 'Warning', or 'Error'.

No comments:

Post a Comment

I moderate comments blog posts over 14 days old. This keeps a lot of spam away. I generally am all right about moderating. Thanks for understanding.