---
title: "Enable Application Insights logging in Sitecore XC"
slug: "enable-application-insights-logging-in-sitecore-xc"
abstract: "Enable Application Insights logging to monitor and troubleshoot the performance of a Commerce application."
---
# Enable Application Insights logging in Sitecore XC

When you deploy Sitecore Experience Commerce™ (XC) in a Microsoft Azure® App Service configuration, you can enable Microsoft Application Insights® to monitor the performance of a given instance of the Commerce Engine. Sitecore XC uses a [Serilog sink](https://github.com/serilog/serilog-sinks-applicationinsights) that writes events to Microsoft Azure Application Insights.

To enable Application Insights logging:

1. Open the `config.json` file of the Commerce environment you want to monitor using Application Insights logging. For example, ` C:\inetpub\wwwroot\CommerceShops_Sc9\wwwroot\config.json`.
2. In the `"ApplicationInsights"` section, set the `"InstrumentationKey"` parameter, to determine the Application Insights resource in which your data appears. For example:

    ```csharp
    "ApplicationInsights": {
        "InstrumentationKey": "YourInstrumentationKey",
    },
    ```

3. In the `"Serilog"` configuration section, ensure that the `"Using"` statement includes the relevant sinks. For example:

    ```

    "Serilog": {
       "Using": [
         "Serilog.Sinks.Literate",
         "Serilog.Sinks.File",
         "Serilog.Sinks.ApplicationInsights"
    ]
       "MinimumLevel": {
          "Default": "Warning",
          "Override": {
            "Microsoft": "Warning",
            "System": "Warning"
    ```

    > [!note]
    > The default Serilog configuration uses both `"Serilog.Sinks.File"` and `"Serilog.Sinks.ApplicationInsights"` sinks. To avoid duplication and control cost related to cloud storage, you should consider removing the `Serilog.Sinks.File` sink from the configuration.

4. In the `"Serilog"` configuration, in the `"WriteTo"` subsection, specify where to send log data. By default, Sitecore XC is configured to send log data to `ApplicationInsights`. For example:

    ```csharp
    "WriteTo": [
          {
            "Name": "ApplicationInsights",
            "Args": {
              "restrictedToMinimumLevel": "Warning",
              "telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
            }
          }
        ],
    ```

    > [!note]
    > You can set the `restrictedToMinimumLevel` parameter to a value that is noisier than the value of the `MinimumLevel` specified in the Serilog configuration. However, the value of the `MinimumLevel` parameter always takes precedence when it is more restrictive.