Sitecore writes log information to Microsoft Application Insights® when running on the Microsoft Azure® App Service.
In Application Insights, you can identify error and warning messages, identify messages from specific roles and Sitecore instances, and search for specific log messages.
This topic outlines how to:
- Search Sitecore logs using Application Insights
- Find log messages by time range
- Find log messages for a specific Sitecore role
- Find log messages by level of severity
- Explore log message details
Search Sitecore logs using Application Insights
Using Application Insights, you can search for a particular word or subscription in Sitecore logs.
- Go to the HYPERLINK "https://portal.azure.com/"Microsoft Azure Portal and log on.
- On the Dashboard, click All resources, and select your Sitecore installation from the list of provisioned Azure resources.
- Click the Application Insights resource. When the page opens, on the toolbar, click Search.
- In the Search panel that appears on the right side, type your key search words in the Search box and click Enter.
- At the top of the Search panel, click Filters.
- In the Filter panel that appears on the right side, under Event Types, clear all of the checkboxes except for the Trace and Exception checkboxes.
- To see the Trace events, at the bottom of the panel, click Update.
Find log messages by time range
Using Application Insights, you can narrow down search results to a specific time range.
- In the Azure Portal, at the top of the Search page, click Time range.
- In the Time Range panel that appears on the right side, select the relevant recent time range (for example, 30 minutes or 1 hour), or specify a custom date and time range.
- At the bottom of the panel, click Update.
The search results only show messages that fall within the specified timespan.
Find log messages for a specific Sitecore role
All Sitecore instances in a Sitecore environment share the same Application Insights resources. This means that you can use Application Insights to narrow down your search to a specific Sitecore role (for example, CD, CM, Processing, or Reporting):
- In the Azure portal, at the top of the Search page, click Filters.
- In the Filter panel that appears on the right side, expand the Role tab.
- Select the role you want visible in your search results.
- To see the log messages for the selected role, at the bottom of the panel, click Update.
Find log messages by level of severity
Sitecore translates Log4net message severity levels into Application Insights Trace severity levels. The four supported severity levels are Error, Warning, Informational, and Verbose. For example, to search for Error and Warning messages only:
- In the Azure portal, at the top of the Search panel, click Filters.
- In the Filter panel that appears on the right side, expand the Severity level tab.
- Select the Error and Warning checkboxes.
- To see the log messages with severity levels of Error and Warning, at the bottom of the panel, click Update.
Explore log message details
When the Search page displays log messages or other events, you can click on an item to see its details. An event details panel appears on the right side and contains information about the log message, including the following Trace properties:
- The Web App Instance ID from the origin of the log message.
- The message text of the log file. (To display the full message text on a new page, click the ellipsis button near the text.)
- A full stack trace of the exception (for exception events only).
For a log message or exception, use the event details panel to navigate to related telemetry events, such as:
- Events in the same logical operation, for example, in an ASP.NET request. This means you can see the URL of the request that caused the exception and also the log messages for a slow request.
- Events with the same Web App Instance ID. This means you can identify which events happened in the same Sitecore instance as the original event.
- Events that occur within 5 minutes before or after the original event. This means you can scan the entire Sitecore environment to identify which events happened close to the original event.
You can also use these navigation options to open new Search pages and explore what the Sitecore behavior was at the time a particular event occurred. This helps you to identify the root cause, an exception, or a particular behavior. The Microsoft Azure website provides more diagnostic search documentation about using the Application Insights Search functionality.