What's a good approach to adding debug code to your application when you want more info about what's going wrong?

Posted by Andrei on Programmers See other posts from Programmers or by Andrei
Published on 2011-11-23T10:43:42Z Indexed on 2011/11/23 18:03 UTC
Read the original article Hit count: 506

Filed under:
|
|
|

When our application doesn't work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say.

But I don't want all this debug code to be in the production code, since this would create some really big debug files with information that is not always relevant.

The other problem is that our code base changes, and the next time, the same debug code might have to go in different parts of the application.

Questions

Is there a way to merge this debug code within the production code only when needed and have it appear at the correct points within the application?

Can it be done with a version control system like git so that all would be needed is a git merge?

P.S. The application I'm talking about now is .NET, written in C#.

© Programmers or respective owner

Related posts about c#

Related posts about .NET