Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ref Line # in Try Catch Finally an E-mail Line #

Status
Not open for further replies.

R7Dave

Programmer
Oct 31, 2007
181
US
Hello

Using a Try Catch Finally Statement - I want to e-mail myself an error message that contains the page and line # when the code steps into the Catch (...is an error)

Does anyone know how to do this?

Thanks in advance
Dave
 
logging is a solved problem. libraries like log4net, nlog and ent. lib. X Logging all work.

there are best practices to try/catch/finally. google for more info. I simply place logging in the global.ascx file by creating a handler for the Error event. logging and redirecting to a friendly page. it looks like this
Code:
public class Global : HttpApplication
{
   private static readonly ILog logger = LogManager.GetLoggers(typeof(Global));

   public Global()
   {
       Error += LogError;
   }

   private void LogError(object sender, EventArgs e)
   {
       logger.Error(Server.GetLastError as Exception);
   }
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top