Using the integration port logging mode

Microsoft Dynamics AX 2012 provides the out-of-the-box logging of messages by configuring the logging mode parameter on integration ports. This is available on both basic and enhanced, inbound and outbound ports, and for document services as well as custom services.

Logging is disabled by default. As always, when adding logging to any process, take a moment and think about whether adding logging is really necessary. Also consider the level of detail that is required as this will have an impact on the performance of your service. The Logging mode parameter on integration ports provides the following options in the descending order of their level of detail:

  • All document versions: When selected, a version of the document is stored every time a document is modified by a pipeline component
  • Original document: When selected, only the original document before it has been modified by the pipeline components is stored
  • Message header only: Select this option when you want to store only the header of the documents

For this demonstration, we will activate logging on the CVRDocumentServicesEnhanced inbound integration port that we created and configured in Chapter 3, AIF Document Services. We will see which logging occurs when the Find() method is invoked from our demo .NET application.

Configuring the logging mode

The first thing we need to do is activate logging on the integration port as it is disabled by default. In this example, we will log the original document only because we haven't configured any pipeline components anyway. Perform the following steps to set the logging mode:

  1. Go to System administration | Setup | Services and Application Integration Framework | Inbound Ports.
  2. Select the CVRDocumentServicesEnhanced port. When the port is active, click on the Deactivate button to deactivate it.
  3. On the Troubleshooting fast tab, set the Logging mode parameter to Original document.
  4. Activate the CVRDocumentServicesEnhanced port.

Consulting the log

In our demo in Chapter 3, AIF Document Services, we used the Find() method to retrieve all the titles longer than 110 minutes. The code we used to invoke this service looks like the following code snippet:

static void getTitles_Find()
{
    // Variable to hold the title document
    AxdCVRTitle titleDocument = new AxdCVRTitle();

    // Create a criteria element that selects titles that run over 110 
    // minutes
    QueryCriteria criteria = Program.createSingleCriteria("CVRTitle" , "LengthInMinutes", Operator.Greater, "110", null);

    // Create a client for as long as we need to
    using (CVRTitleDocumentServiceClient client = new CVRTitleDocumentServiceClient())
    {
        // Find the titles that match the criteria
        titleDocument = client.find(null, criteria);

        // Loop all the titles
        foreach (AxdEntity_CVRTitle title in titleDocument.CVRTitle)
        {
            // Report the results to the console window
            Console.WriteLine(title.Id + ' ' + title.Name + ' ' + title.LengthInMinutes);
        }
    }
}

With logging enabled, let's see what information is logged after we have invoked this code. To consult the log, go to System administration | Periodic | Services and Application Integration Framework | History. You should see the following form:

Consulting the log

This screen shows all the messages that were logged by the Application Integration Framework. The ordering of this screen isn't particularly good, so it's usually best to sort the messages by created date and time as seen in the previous screenshot. As you can see, two records are present. This is because two messages were sent: a request from the .NET application to the AOS and a reply from the AOS to the .NET application. To see what data was transferred in the body of each message, click on the Document logs button. The following screenshot will pop up:

Consulting the log

In this screenshot, a record of every step that we want to log is listed. Because we indicated that we only want the original document, only one record is listed. To view the data from the message, click on the View XML button; we will arrive at the following screenshot:

Consulting the log

As you can see, it is pretty obvious that this is a request that has been sent to the AOS to retrieve all the titles longer than 110 minutes. The QueryCriteria node in the XML matches the object that we constructed in the .NET application perfectly. To view the data that was returned, you can perform the same steps for the second record that is present in the History form. In the following screenshot, you can clearly see that it contains a list of CVRTitle records:

Consulting the log
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.83.151