Reputation: 7281
I have seen a few different answers on SO that discourage the use of Debug.Print while debugging applications .. but nobody ever goes into exactly why its bad. I googled it, of course, but the results didn't turn up anything usable.
Can anyone clarify why Debug.Print is so bad?
Upvotes: 2
Views: 211
Reputation: 48134
There's really nothing wrong with it, there are just better options.
If you're going to be outputting data you may as well log it. If you do that you actually get something back from the investment.
Additionally printing out variable info is less effective than setting a break point and inspecting those values in the debugger. Particularly in VS where these tools are excellent.
Upvotes: 2
Reputation: 30411
It's noisy - all the debug statements end up mixed together.
It's easily missed - there's a ton of other output in that stream as well, easy to miss stuff.
It doesn't give enough context - there's no stack trace, no current variable values if you forget to include them, etc...
It only goes one place (the debug output) so it's hard to send to a disk file, database, etc.
Basically, it's no good for logging since you can't control where it goes, and it's no good for debugging because the debugger does everything better.
Upvotes: 3