Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. BizTalk Server Instrumentation, Error... > Applying event logging in BizTalk so...

Applying event logging in BizTalk solutions

Applying event logging in BizTalk solutions Logging and tracing in BizTalk can be achieved by using Log4Net or DebugView in combination with System.Diagnostics.Trace or System.Diagnostics.Debug. Previous recipes have shown these options. Both can be used, but do not deliver the desired level of agility and performance according to research conducted by the Application Server Group ISV Partner Advisory Team ( http://blogs.msdn.com/b/asgisv/archive/2010/05/11/best-practices-for-instrumenting-high-performance-biztalk-solutions.aspx). Their findings were as follows: High CPU utilization while using DebugView when monitoring BizTalk applicationsHigh impact on application performance when running DebugView during stress testingBurden on the administrator to restart BizTalk host instance when any changes in the tracing configuration such as enabling, disabling or changing the trace level were required Log4Net and DebugView are not good options to use in production environment when performance is the key factor. Both are more valuable on a developer machine. A better option, the team thought, was to leverage the Event Logging for Windows (ETW) infrastructure that enables you to take advantage of the general purpose, high-speed tracing facility provided by the OS kernel. To use ETW, you do have to use a framework and it is more complex compared to DebugView and Log4Net. The Microsoft's BizTalk Customer Advisory Team (CAT) built a framework on top of the ETW infrastructure. They also built the BizTalk CAT Instrumentation Framework Controller, which is an easy-to-use GUI for the BizTalk CAT Instrumentation Framework. This controller enables you to start and stop a trace and adjust filter options, and can easily enable real-time tracing for Microsoft SysInternals DebugView (or other debuggers), to a log file or to both at the same time. Getting ready Download the BizTalk Solution Instrumentation Framework v1.4 found on MSDN (http://archive.msdn.microsoft.com/appfabriccat/Release/ProjectReleases.aspx?ReleaseId=4355) and the BizTalk CAT Instrumentation Framework Controller on codeplex (http://btscatifcontroller.codeplex.com/). For reference, you can download the source code for CAT (BTS.Cookbook.CAT) belonging to this chapter. How to do it... There are some steps involved to be able to use the Controller to be able to monitor, for instance, an orchestration. First you need to port the Framework to .NET 4 by performing the following steps: Unpack the BizTalk Solution Instrumentation Framework V1.4 to a folder.Open the solution with Visual Studio 2010 and convert.Right-click on the Microsoft.BizTalk.CAT.BestPractices.Framework project and select Properties.Click on the Build tab and change the Target framework to .NET Framework 4.Sign the project with a strong name.Build the project.Use the gacutil command to place the assembly in the GAC: The Microsoft.BizTalk.CAT.BestPractices.Framework.dll assembly is necessary for your BizTalk project as a reference. As an example, we will use the splitter pattern solution that debatches messages in an orchestration (see the Implementing the Splitter Pattern recipe). For enabling tracing in any orchestration by using Microsoft.BizTalk.CAT.BestPractices.Framework, you will have to follow these steps: Create a variable in the Orchestration View window and give it a descriptive name and select the Type as System.Guid.Within orchestration, drag an Expression shape at the start of the orchestration after the Receive shape and add the following statement: <your variable name> = Microsoft.BizTalk.CAT.BestPractices.Framework.Instrumentation.TraceManager.WorkflowComponent.TraceIn(); Add a few more Expression shapes to monitor your orchestration. With examples belonging to this book, you see that before and after the Expression shape (Record Count), and in the Message Loop, Expression shapes are placed with statements like: Microsoft.BizTalk.CAT.BestPractices.Framework.Instrumentation.TraceManager.WorkflowComponent.TraceInfo(System.String.Format("Record count is : {0}",dRecordCount.ToString())); At end of the orchestration an Expression Shape is placed with the following statement: Microsoft.BizTalk.CAT.BestPractices.Framework.Instrumentation.TraceManager.WorkflowComponent.TraceOut(<your variable name>); After you have placed the Expression shapes within your orchestration you can build and deploy your solution. The Controller can be installed by executing the MSI and following the steps in the wizard. You can start the Controller from the Windows menu and you will be presented with a UI, as shown in the following screenshot: You need to perform the following steps to view the trace output in DebugView: Check Orchestration/Workflow as the Trace Filter option.In the File option, select the location of your DebugView tool or the location of where the text file needs to be placed.Click on Start Trace.Click on Launch DebugView.Drop the file to initiate the orchestration. In the DebugView window, you will see the output of the trace, as shown in the following screenshot: How it works... As with other options such as Log4Net and DebugView/System.Diagnostics.Trace (Debug), instrumenting orchestration is the key to help you in diagnosing and troubleshooting behavioral problems in orchestrations or other BizTalk artefacts. Usually, some issues are not foreseen beforehand and are manifested during development. With implementing tracing using the BizTalk CAT Instrumentation Framework, you can leverage tracing capabilities with a high level of agility. The framework can be used within maps, business rules, business activity, and so on. With orchestration example, you see that an entry point is recorded using TraceIn immediately at the first available opportunity; for example, after the first Receive shape. Then the internal state of orchestrations is traced; for example, messages, result of the XPath queries, and so on. Finally, the exit point from an orchestration is recorded using TraceOut at the very last step in the orchestration. There's more... The article by the advisory team at http://blogs.msdn.com/b/asgisv/archive/2010/05/11/best-practices-for-instrumenting-high-performance-biztalk-solutions.aspx lists more possibilities to leverage the BizTalk CAT Instrumentation Framework by tracing events in the following: Custom Pipeline ComponentsBizTalk MapsBusiness RulesCustom Components More background information on ETW can be found in MSDN magazine for April 2007 at http://msdn.microsoft.com/en-us/magazine/cc163437.aspx and introduction of the ETW article at http://blogs.msdn.com/b/matt_pietrek/archive/2004/09/16/230700.aspx. Finally, in the BizTalk Hotrod issue 2010, Q2 you can find an article by Valery Minonov called Instrumentation Best Practices for High Performance BizTalk Solutions at http://biztalkhotrod.com/Documents/Issue10_Q2_2010.pdf. See also The Tracing BizTalk applicationss using DebugView and Monitoring BizTalk solution behavior with Log4Net recipes for more details on other options for monitoring behavior in BizTalk solutions.

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint