By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,423 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,423 IT Pros & Developers. It's quick & easy.

Information which could help to reproduce the exception

P: n/a
QC
Hi Friends,
I have one Application running on Client PC, i coded to store all
Debug, Info, and Trace related information in Log file. This log file
helps me to analyze the exception if any generated in my Application.
Related to exception, i only stores information passed Exception (or
related exception type class) class (ToString(), Message property).
After analyzed and corrected so many exceptions using Logs in last 3
year, I am realizing that I should have sometime which will give me
more detail information e.g. what was the value of all input
parameters of the method where exception generated, or lot more
information which could help me to reproduce the exception at my
development station. I really donít know what exactly it could be but
I am sure about one thing that it should be helpful to reproduce the
error.

I was thinking upon one that store more detail in log file but in this
case the performance will effect.

I just created this Discussion to get the view from all of you, and
all available different ways.
Jun 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 11, 11:30*am, QC <AKhandelwal.in...@gmail.comwrote:
Hi Friends,
* * *I have one Application running on Client PC, i coded to store all
Debug, Info, and Trace related information in Log file. This log file
helps me to analyze the exception if any generated in my Application.
Related to exception, i only stores information passed Exception (or
related exception type class) class (ToString(), Message property).
After analyzed and corrected so many exceptions using Logs in last 3
year, I am realizing that I should have sometime which will give me
more detail information e.g. what was the value of all input
parameters of the method where exception generated, or lot more
information which could help me to reproduce the exception at my
development station. I really donít know what exactly it could be but
I am sure about one thing that it should be helpful to reproduce the
error.

I was thinking upon one that store more detail in log file but in this
case the performance will effect.

I just created this Discussion to get the view from all of you, and
all available different ways.

I think you can use Log4Net, which can be configured to log the
information like datetime of the error, error levels, and even to the
level which method / class / line of code generated the error. Only
constraint is that you have to put log statements explicitly and
generously.

-Cnu
Jun 27 '08 #2

P: n/a
QC
On Jun 11, 11:45*am, Duggi <DuggiSrinivasa...@gmail.comwrote:
On Jun 11, 11:30*am, QC <AKhandelwal.in...@gmail.comwrote:


Hi Friends,
* * *I have one Application running on Client PC, i coded to storeall
Debug, Info, and Trace related information in Log file. This log file
helps me to analyze the exception if any generated in my Application.
Related to exception, i only stores information passed Exception (or
related exception type class) class (ToString(), Message property).
After analyzed and corrected so many exceptions using Logs in last 3
year, I am realizing that I should have sometime which will give me
more detail information e.g. what was the value of all input
parameters of the method where exception generated, or lot more
information which could help me to reproduce the exception at my
development station. I really donít know what exactly it could be but
I am sure about one thing that it should be helpful to reproduce the
error.
I was thinking upon one that store more detail in log file but in this
case the performance will effect.
I just created this Discussion to get the view from all of you, and
all available different ways.

I think you can use Log4Net, which can be configured to log the
information like datetime of the error, error levels, and even to the
level which method / class / line of code generated the error. Only
constraint is that you have to put log statements explicitly and
generously.

-Cnu- Hide quoted text -

- Show quoted text -
Thanks for your view...
Yes, but as per my knowledge, these all information can be found in
Exception Class as well, right?
also, log4net stores those information which passed by application.

Jun 27 '08 #3

P: n/a
QC
On Jun 11, 11:53*am, QC <AKhandelwal.in...@gmail.comwrote:
On Jun 11, 11:45*am, Duggi <DuggiSrinivasa...@gmail.comwrote:


On Jun 11, 11:30*am, QC <AKhandelwal.in...@gmail.comwrote:
Hi Friends,
* * *I have one Application running on Client PC, i coded to store all
Debug, Info, and Trace related information in Log file. This log file
helps me to analyze the exception if any generated in my Application.
Related to exception, i only stores information passed Exception (or
related exception type class) class (ToString(), Message property).
After analyzed and corrected so many exceptions using Logs in last 3
year, I am realizing that I should have sometime which will give me
more detail information e.g. what was the value of all input
parameters of the method where exception generated, or lot more
information which could help me to reproduce the exception at my
development station. I really donít know what exactly it could be but
I am sure about one thing that it should be helpful to reproduce the
error.
I was thinking upon one that store more detail in log file but in this
case the performance will effect.
I just created this Discussion to get the view from all of you, and
all available different ways.
I think you can use Log4Net, which can be configured to log the
information like datetime of the error, error levels, and even to the
level which method / class / line of code generated the error. Only
constraint is that you have to put log statements explicitly and
generously.
-Cnu- Hide quoted text -
- Show quoted text -

Thanks for your view...
Yes, but as per my knowledge, these all information can be found in
Exception Class as well, right?
also, log4net stores those information which passed by application.- Hide quoted text -

- Show quoted text -
Is there also any way to get/store the detail information (each
Variable value, passed parameter value, result of any method,
calculation) of last 10 or 6 methods? In short like when debugging we
can check the value of each object/ result to find out reason of
exception. In the same manner the information can be found somewhere,
please let me know if we have any way.
Jun 27 '08 #4

P: n/a
Hi QC,

If you want to know what gets sent to the method you will need to log that
specifically. You can, however, minimize the amount of code needed by
creating a common logging method that can take unlimited variations of input
by using the params keyword

public Form1()
{
InitializeComponent();

Method("Hello World");
}

private void Method(string message)
{
try
{
throw new InvalidDataException("Bye bye");
}
catch (Exception ex)
{
LogError(ex, message);
}
}

private void LogError(Exception ex, params object[] parameters)
{
StackFrame frame = new StackFrame(1);
MethodBase mb = frame.GetMethod();
string methodName = mb.Name;
ParameterInfo[] pis = mb.GetParameters();

StringBuilder sb = new StringBuilder();
sb.Append(mb.Name + "(");

foreach(object o in parameters)
sb.Append(o + ", ");

if (parameters.Length 0)
sb.Remove(sb.Length - 2, 2);

sb.Append(")");

MessageBox.Show(sb.ToString());
}

--
Happy Coding!
Morten Wennevik [C# MVP]
"QC" wrote:
On Jun 11, 11:45 am, Duggi <DuggiSrinivasa...@gmail.comwrote:
On Jun 11, 11:30 am, QC <AKhandelwal.in...@gmail.comwrote:


Hi Friends,
I have one Application running on Client PC, i coded to store all
Debug, Info, and Trace related information in Log file. This log file
helps me to analyze the exception if any generated in my Application.
Related to exception, i only stores information passed Exception (or
related exception type class) class (ToString(), Message property).
After analyzed and corrected so many exceptions using Logs in last 3
year, I am realizing that I should have sometime which will give me
more detail information e.g. what was the value of all input
parameters of the method where exception generated, or lot more
information which could help me to reproduce the exception at my
development station. I really don’t know what exactly it could be but
I am sure about one thing that it should be helpful to reproduce the
error.
I was thinking upon one that store more detail in log file but in this
case the performance will effect.
I just created this Discussion to get the view from all of you, and
all available different ways.
I think you can use Log4Net, which can be configured to log the
information like datetime of the error, error levels, and even to the
level which method / class / line of code generated the error. Only
constraint is that you have to put log statements explicitly and
generously.

-Cnu- Hide quoted text -

- Show quoted text -

Thanks for your view...
Yes, but as per my knowledge, these all information can be found in
Exception Class as well, right?
also, log4net stores those information which passed by application.

Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.