Configure HTTP request logging

Version: 10.4

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.

RequestResponse
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).

    RequestResponse
    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).

    RequestResponse
    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.

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

Do you have some feedback for us?

If you have suggestions for improving this article,