Error Logging is main part of our database application. I am trying to share some sample code which I am using in my daily life.
We need to follow below steps.
1) Create database.
2) Create Error Log Table.
Table: Error_Log
Columns:
4) Create Procedure with error which used Error Log Procedure in 3rd Step.
5) Execute Parent Procedure. Below is error output from Parent Procedure.
66) Check logs in Error Log table.
7) Create Config Table. Add below entry for Mail Configuration.
9) Create Job to execute Procedure to send alert mails. Below is alert mail.
Below are the scripts to download.
Error Logging and Alerts.sql
We need to follow below steps.
1) Create database.
2) Create Error Log Table.
Table: Error_Log
Columns:
- Log_ID
- Identity column.
- Database_Name
- Database Name.
- Proc_Name
- Procedure Name.
- Err_Number
- Error Number from Procedure.
- Err_State
- Error Stage from Procedure.
- Err_Message
- Error Message from Procedure.
- Err_Line
- Error Line from Procedure.
- Created_Date
- Default current date from database.
4) Create Procedure with error which used Error Log Procedure in 3rd Step.
5) Execute Parent Procedure. Below is error output from Parent Procedure.
66) Check logs in Error Log table.
7) Create Config Table. Add below entry for Mail Configuration.
- Mail_From
- Mail_Subject_Error_Log_Alert
- Mail_To
9) Create Job to execute Procedure to send alert mails. Below is alert mail.
Below are the scripts to download.
Error Logging and Alerts.sql
No comments:
Post a Comment