Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4550726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:32:10+00:00 2026-05-21T16:32:10+00:00

Our application is Windows Service (native .EXE written in C++) that calls stored procedures

  • 0

Our application is Windows Service (native .EXE written in C++) that calls stored procedures in SQL Server. In most cases errors in stored procedures (in 90% of the cases these errors mean something was wrong in our business logic) are re-thrown as exception and caught by our service. They are then logged in Application Event Log on the computer where our service is running.

However, I now have a need to log some of the errors on the SQL Server itself within a stored procedure.

Following the paradigm we use for our service I think I can use xp_logevent to save error information in the event log.

Is this a recommended approach to log SQL Server errors?

FWIW I use SQL Server 2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:32:11+00:00Added an answer on May 21, 2026 at 4:32 pm

    The How To

    You can always use RAISEERROR() WITH LOG. Logs to both Windows Application log and the SQL error log.Please note that severity level is key here. There are some limitations and security considerations, but you get some other features also.
    More details in BOL:
    http://msdn.microsoft.com/en-us/library/ms178592.aspx

    The Should you

    My opinion is that you shouldn’t log anything to SQL error log unless it’s generated by SQL server itself. Multiple reasons:

    1. If your IT or DBA uses log analyzer or any other tool, it may trip an alarm on an application issue, instead of the server issue (this is what they are trying to catch).
    2. I never found parsing error logs enjoyable from within SQL server, and I’m not particularly in love with SSMS’s way of doing it.

    My suggestion

    Use a generic logging stored procedure writing to some error log table. A very nice patter is

    BEGIN TRY
    ...do your stuff
    END TRY
    BEGIN CATCH
      get the ERROR_LINE(), ERROR_MESSAGE() and friends
      execute generic logging procedure
    END  CATCH
    

    As a bonus, you can use SSSB within the logging procedure to make it async and not impede the main logic flow

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our application is a Windows client (C++/MFC migrating to C#) that uses SQL Server
I have an server application (running as a Windows Service) that receives calls from
I have a Windows Service written in C# that handles all of our external
Our application is written in C++ and used on Windows XP. On some client
We're currently using IIS 6 and Windows Server 2003 for our web and application
I've got a web application that is running against Windows Authentication using our Active
I wrote a C# Windows Service to handle task scheduling for our application. I'm
enter code here Hi All, I have a simple windows service application that connects
Our Windows Forms application by default saves data files in a user's 'My Documents'
I have moved a component of our application from a webservice to a Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.