pointeman
asked on
TraceListener vs Try-Catch?
Q. What's the difference between using TraceListeners and placeing a Try-Catch on every method???
Q. Looks like I would need a Try-Catch anyway in order to use the Trace.WriteLine method???
I've been using the following code on every method to catch errors. It calls a class implementing a StreamWriter to write both method() name and exception message to a c:\log.txt...... The log.tx is also encrypted to keep prying eyes from reading the detailed exceptions (ie... methods, line numbers, etc...) Encryption can also be disabled for my eyes only or I can decrypt a log sent to me from a client.
Try
{
//code....
}
catch (Exception ex)
{
EventLogWriter.Write(" Form1_Load() " + ex.ToString(), "Error");
}
Q. Looks like I would need a Try-Catch anyway in order to use the Trace.WriteLine method???
I've been using the following code on every method to catch errors. It calls a class implementing a StreamWriter to write both method() name and exception message to a c:\log.txt...... The log.tx is also encrypted to keep prying eyes from reading the detailed exceptions (ie... methods, line numbers, etc...) Encryption can also be disabled for my eyes only or I can decrypt a log sent to me from a client.
Try
{
//code....
}
catch (Exception ex)
{
EventLogWriter.Write(" Form1_Load() " + ex.ToString(), "Error");
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a StackTrace setup in a web site global.asax that reports any errors occuring via email.
Too bad Window Apps don't have this ability.
I was hoping the Win App Tracing/Debugging offered something similar.
Too bad Window Apps don't have this ability.
I was hoping the Win App Tracing/Debugging offered something similar.
ASKER
Q. Which is better, the class or .config file?
Q. Does the TraceListener automatically log messages or do have to continually use a Trace.WriteLine?
It would be nice if the TraceListener class could be initialized when the application starts...