开发者

Use sp_addmessage to Write to EventLog with different Event ID

开发者 https://www.devze.com 2023-02-18 00:54 出处:网络
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_addmessag

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号