Click here to Skip to main content
15,910,234 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if we open any UI page and it is getting any error means that error should be saved in to the error log table which we are maintaining in the database how to do this .
Posted

1 solution

If you want to log the errors put your code into try-catch block and log the error in catch statement.

An example pseudo code;
C#
try
{
 //your code in the page
}
catch(Exception ex)
{
  //open a DB connection
  //Insert the exception details to your table
  // close your connection after inserting
}


You can also use your global.asax file as well.
Here are some example links to give you an idea:
Create Simple Error Log Files using ASP.NET and C#[^]
Logging Error Details with ASP.NET Health Monitoring(C#)[^]
Event and Error Logging[^]


Beware here though. When you use try-catch it will swallow the exception so you might want to notify the user with a client-sided message box or something similar.

Good luck,
OI
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900