Use sp_addmessage to Write to EventLog with different Event ID
I have bunch of custom messages in SQL Server that I am writing to event log and I never realized that they all writing with same EVENTID 17063 in Application Event Log, how can I specify sp_addmessage to write a custom EvenID so that all are not logged with EVENTID 17063 ?
EXEC开发者_运维问答 sp_addmessage @msgnum = 90002, @severity = 16, @msgtext = N'some text', @lang = 'us_english', @with_log = 'TRUE', @replace = 'replace' ; ReplyQuote
I believe that EVENTID 17063 indicates that the source for the event is SQL Server, so that is not something that you can change using the sp_addMessage stored procedure.
However, if you're able to use CLR, you can create a wrapper around the EventLog.WriteEntry method, which would allow you to change the EVENTID.
http://msdn.microsoft.com/en-us/library/f6wy11we.aspx
精彩评论