Showing posts with label Trace Logs. Show all posts
Showing posts with label Trace Logs. Show all posts

Friday, 19 January 2018

Logging With Log4Net | Console App | Parallel Vs Delegate


In this article, we will see how to enable logging using log4net and see the advantage of using Parallel Invoke over delegate.
Here is the simple console and I added the reference of Log4net; using log4net api I added tracing statements as shown.
I have used delegate to invoke LogM1 and LogM2 methods that would in turn invoke M1 and M2 methods using Parallel For Loop, M1 and M2 writes the trace details as shown below.
Lets run and verify the logs. Though, we use delegate to invoke the methods, we clearly see, M2 is invoked or started; post completion of M1 method. As Parallel FOR loop invokes M1 and M2, logging are captured in a random manner.
Instead of delegate, lets now refactor the code to use Parallel Invoke method as shown below.
Lets run and verify the behaviour. Both M1 and M2 are parallel invoked and all the logs are captured in a random manner; execution time is also faster comparatively to earlier way using delegate.

Thursday, 12 October 2017

Enabling Logging Mechanism in BizTalk Server | Tracing using Log4Net


In this article, we will see now to enable logging using log4net with BizTalk. I have an existing pass through BizTalk application, which receives message using file adapter and through orchestration pushes it to another folder location.

Lets build a custom logger; add the reference of Log4net and implement custom logger using using the Log4net as shown below,

Build and Gac the custom logger library and add this reference to BizTalk project. Add a variable of logger class and then start logging traces using custom logger inside expersion shape as shown below.
Lets run and verify the logs.

BizTalk Server 2016 | Application Insight Logging | Azure-BizTalk


In this article, I will explain the steps involved in sending BizTalk tracking data/trace details to Azure Application Insights.

Lets create an instance of Application Insights in Azure portal as shown below, 
  • Log on to Azure portal and add a new application insights instance and Provide an appropriate name. 
  • Choose application type as General. 


Make sure you Download the BizTalk Server 2016 Feature Pack 1; this update enables BizTalk to integrate with Azure Application Insight. Once the feature pack is installed, we can see a section called “Analytics” in BizTalk Group hub settings page.
Once the analytics is configured at the group level, now we can enabling tracking at individual artifacts level, as shown below.
I have enabled the Analytics for send port, receive and orchestration. This ensures that all the data will be pushed to Application insights. From Application Insight azure portal; You can explore these metrics and create graphs for data visualization; once the data is pumped to Application Insights.


Below are few pointers on AppInsight logging mechanism for BizTalk. 
  • Captures analytics on BizTalk Message Box only.
  • Context Properties available on messages are captured in App Insight.
  • For Physical Ports 2 entries are made (Receive and Send | Publish Subscriber)
  • For each logical Port, an entry is made (Orchestration)
  • There should be a dedicated Send Port for routing exception message to capture exceptiondetails in App Insight.
  • Analytics can be captured at Ports and Orchestrations. It’s not mandate to enable tracking at ports and orchestrations; enabling analytics is sufficient.
  • Orchestration entries are captured with respect to logical ports. If call or start orchestration doesn’t have any logical ports; analytics entries for these orchestration aren’t captured.
Here is my simple helper class using this we could capture the trace details from orchestration.
This is my simple orchestration, which would send the trace logs to application insight using the helper class.
As you can see the logs are available under traces.