ASP.NET Console Debug Logging

I ran into an unexpected thing today. I was trying to get a debug line to print in the output console in Visual Studio for an ASP.NET site I’m working on, and it didn’t make sense to me. I eventually figured it out, and decided to make a note of it because I know I will probably need it again, and also know that it might help someone else.

At the top of the file, add this:
using System.Diagnostics;

In the code that you want to print to Visual Studio output window:
Debug.WriteLine("Skipping directory: {0}", accountDirectory);

That’s it. I hope this helps someone else out there.

-Adrian

Leave a Reply

Your email address will not be published. Required fields are marked *