Configure HTTP request logging

Abstract

How to configure HTTP request logging to track HTTP requests and responses to xConnect.

Extended xConnect logging can track HTTP requests and responses to xConnect. It is disabled by default.

Enable HTTP request logging

To enable HTTP request logging:

  • Enable the file \App_Data\Config\Sitecore\CoreServices\sc.XConnect.RequestLogging.Web.Host.xml.disabled by renaming the file to \App_Data\Config\Sitecore\CoreServices\sc.XConnect.RequestLogging.Web.Host.xml.

HTTP request log output example

The log output contains a request (method, URI, HTTP headers, request content) and a response (URI, status code, HTTP headers, and content). You can match requests and responses with the Id field.

2021-06-03 14:28:35.167 +03:00 [Verbose] Sending HTTP request Http trace 
{ 
  "Id": 13621, 
  "HttpMethod": { 
    "Method": "POST" 
  }, 
  "Uri": "https://xcp_xconnect/odata/Contacts(44f965ad-28dd-4095-91b6-69e77e696daa)/Interactions", 
  "HeadersInfo": [ 
    { 
      "Key": "Host", 
      "Value": [ 
        "xcp_xconnect" 
      ] 
    }, 
    { 
      "Key": "OData-Version", 
      "Value": [ 
        "4.0" 
      ] 
    }, 
    { 
      "Key": "Accept", 
      "Value": [ 
        "application/json; odata.metadata.context=false" 
      ] 
    }, 
    { 
      "Key": "Content-Type", 
      "Value": [ 
        "application/json; charset=utf-8; odata.metadata.context=false" 
      ] 
    }, 
    { 
      "Key": "Content-Length", 
      "Value": [ 
        "643" 
      ] 
    } 
  ], 
  "Content": "{\"ChannelId\":\"7886e1f5-b85c-484b-bfee-0cb3678dbf0a\",\"StartDateTime\":\"2021-06-03T11:49:14.5869922Z\",\"EndDateTime\":\"2021-06-03T11:49:44.5869922Z\",\"Duration\":\"PT30S\",\"Events\":[{\"@odata.type\":\"#Sitecore.XConnect.Collection.Model.PageViewEvent\",\"CustomValues\":[],\"DefinitionId\":\"9326cb1e-cec8-48f2-9a3e-91c7dbb2166c\",\"ItemId\":\"110d559f-dea5-42ea-9c1c-8a5df7e70ef9\",\"Id\":\"e61bcbad-e464-4e60-afce-0c7004fd20c0\",\"Text\":\"Parent Event: 9326cb1ecec848f29a3e91c7dbb2166c\",\"Timestamp\":\"2021-06-03T11:49:14.5869922Z\",\"Duration\":\"PT30S\",\"ItemLanguage\":\"ja-JP\",\"ItemVersion\":1}],\"UserAgent\":\"abc4f918-b686-4e1e-9c2e-dfa4cbfd1a69\",\"Contact\":{\"@odata.id\":\"$2\"}}" 
} 
 
2021-06-03 14:28:35.167 +03:00 [Verbose] Received HTTP response Http trace 
{ 
  "Id": 13621, 
  "Uri": "https://xcp_xconnect/odata/Contacts(44f965ad-28dd-4095-91b6-69e77e696daa)/Interactions", 
  "StatusCode": 200, 
  "Duration": "00:00:00.0002137", 
  "HeadersInfo": [ 
    { 
      "Key": "Content-Type", 
      "Value": [ 
        "application/json" 
      ] 
    } 
  ], 
  "Content": null 
} 

Change the log details for HTTP request logging

It is possible to change the log details for HTTP request logging. You can choose one of the following values:

  • OnlyRequest (log the request and response without headers and content).

    2021-06-03 17:05:10.456 +03:00 [Verbose] Sending HTTP request Http trace 
    { 
      "Id": 4, 
      "HttpMethod": { 
        "Method": "GET" 
      }, 
      "Uri": "https://xcp_xconnect:443/odata/Contacts?%24filter=Id+eq+4b1e26d2-7988-0000-0000-062609cf16cb&%24expand=Identifiers,MergeInfo,ConsentInformation", 
      "HeadersInfo": null, 
      "Content": null 
    } 
     
    2021-06-03 17:05:10.460 +03:00 [Verbose] Received HTTP response Http trace 
    { 
      "Id": 4, 
      "Uri": "https://xcp_xconnect:443/odata/Contacts?%24filter=Id+eq+4b1e26d2-7988-0000-0000-062609cf16cb&%24expand=Identifiers,MergeInfo,ConsentInformation", 
      "StatusCode": 200, 
      "Duration": "00:00:00.0036468", 
      "HeadersInfo": null, 
      "Content": null 
    }
  • RequestWithHeaders (log the request and response headers without content information).

    2021-06-03 17:07:13.475 +03:00 [Verbose] Sending HTTP request Http trace 
    { 
      "Id": 4, 
      "HttpMethod": { 
        "Method": "GET" 
      }, 
      "Uri": "https://xcp_xconnect:443/odata/Contacts?%24filter=Id+eq+8a167bdf-922c-0000-0000-062609e1e7c7&%24expand=Identifiers,MergeInfo,ConsentInformation", 
      "HeadersInfo": [ 
        { 
          "Key": "Accept", 
          "Value": [ 
            "application/json; odata.metadata.context=false" 
          ] 
        }, 
        { 
          "Key": "Host", 
          "Value": [ 
            "xcp_xconnect" 
          ] 
        }, 
        { 
          "Key": "OData-Version", 
          "Value": [ 
            "4.0" 
          ] 
        } 
      ], 
      "Content": null 
    } 
     
    2021-06-03 17:07:13.480 +03:00 [Verbose] Received HTTP response Http trace 
    { 
      "Id": 4, 
      "Uri": "https://xcp_xconnect:443/odata/Contacts?%24filter=Id+eq+8a167bdf-922c-0000-0000-062609e1e7c7&%24expand=Identifiers,MergeInfo,ConsentInformation", 
      "StatusCode": 200, 
      "Duration": "00:00:00.0043318", 
      "HeadersInfo": [ 
        { 
          "Key": "Content-Type", 
          "Value": [ 
            "application/json" 
          ] 
        } 
      ], 
      "Content": null 
    } 
  • Full (log all the information from the request and response).

The detail of HTTP request logs is set to Full by default.

To change the log details:

  • Open the config file \App_Data\Config\Sitecore\CoreServices\sc.XConnect.RequestLogging.Web.Host.xml and modify the value of the Settings/Sitecore/XConnect/Services/HttpRequestLoggingConfiguration/Options/HttpRequestAndResponseLogLevel node.

    <Options>
        <HttpRequestAndResponseLogLevel>Full</HttpRequestAndResponseLogLevel>
    </Options>