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 that writes events to Microsoft Azure Application Insights.
To enable Application Insights logging:
-
Open the
config.jsonfile of the Commerce environment you want to monitor using Application Insights logging. For example,C:\inetpub\wwwroot\CommerceShops_Sc9\wwwroot\config.json. -
In the
"ApplicationInsights"section, set the"InstrumentationKey"parameter, to determine the Application Insights resource in which your data appears. For example: -
In the
"Serilog"configuration section, ensure that the"Using"statement includes the relevant sinks. For example:NoteThe 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 theSerilog.Sinks.Filesink from the configuration. -
In the
"Serilog"configuration, in the"WriteTo"subsection, specify where to send log data. By default, Sitecore XC is configured to send log data toApplicationInsights. For example:NoteYou can set the
restrictedToMinimumLevelparameter to a value that is noisier than the value of theMinimumLevelspecified in the Serilog configuration. However, the value of theMinimumLevelparameter always takes precedence when it is more restrictive.