Quick and dirty debug logging in Biztalk

As an integration developer its sometimes hard to understand how your orchestration is behaving. You might feel that the built in debugging options are not enough. In those cases, a quick and dirty trick to understand the behavior of my executing orchestrations I usually quickly set up debugview and use Systems.Diagnostics.Debug write-outs to understand what’s happening.I am aware that this might not be the best way of doing things. Using the Systems.Diagnostics does impact your performance, so always compile for release when making your deployment package for the Production environment ( we all do that – right? ) .

For more information about a better, somewhat more complicated, way of tracing your application, see: http://blogs.msdn.com/b/appfabriccat/archive/2010/05/11/best-practices-for-instrumenting-high-performance-biztalk-solutions.aspx

So, you are still here? Still want to learn some dirty little secrets about how you can quickly get your orchestration to tell you some valuable variables values? Ok, lets go.

First of all, download debugview. For example from technet: https://technet.microsoft.com/en-us/library/bb896647.aspx

Start debugview as an administrator

Configure debugview to capture what you need to see:

In orchestration, add a expression, use the following code

System.Diagnostics.Debug.WriteLine("The expression you would like to see in debugview");

I usually add both a timestamp and the name of the orchestration to my debug information:

System.Diagnostics.Debug.WriteLine(System.DateTime.Now.ToString("HH:mm:ss") +  ": " + Microsoft.XLANGs.Core.Service.RootService.Name + ": Started orchestration");

And voila!  Just run the orchestration and check the output in debugview to see whats really happening inside your code! Good luck!