Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I want to catch the all errors occurred in the application.


I have used Try catch in all events and functions. in the catch I have Throw the exception message.

Now I want to store on a File or a table with the information( Date time,error message,Form name)

is there any way to capture all exception in a single place or I need to write code for all the catch blocks..



how can I do this?


Regards,
Pal
Posted

Might be good place to start with AnLogger - ASP.NET Logger[^]

Hope it helps
 
Share this answer
 
Comments
VJ Reddy 19-Apr-12 12:04pm    
Good reference. 5!
Mohammad A Rahman 19-Apr-12 17:53pm    
Thanks VJ :)
Create a Logger method and pass the exception data to the Logger.

Something like this should do

C#
public static class Logger
    {
         string logFilePath ;
        private SetLogFilePath();
        public LogMessage(string Message);

    }


Call the log method in all catch blocks.if you looking for something that catches all the applcation errors then this thread will help you.

http://stackoverflow.com/questions/337702/c-sharp-how-to-implement-one-catchem-all-exception-handler-with-resume[Catch all errors in the application]

But my suggestion would be to use individual exception handlers rather than doing all once.As in windows if application level exception is caught and handled application continues to run but will not respond to any of the user actions like button click events and other events will not work until the application is restarted.
 
Share this answer
 

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