If you’re new to the world of Sitecore in Azure PaaS then there’s a good chance that you popped open kudu and browsed to the App_Data/Logs folder and said to yourself “oh yeah, it’s in Application Insights or something…”. Then after going to Application insights and pushing buttons haphazardly arrived at something that kind of looks like log. It can be confusing and concerning to feel like you have an inability to debug problem. I’m going to go over the various ways of retrieving debug information for your Sitecore App Services.
This is where the vast majority of your logs are going to be, it’s not a great format and leaves me wanting more from the tool, but here’s how you use it:
- Navigate to your sites Application insights Azure resource
- In the Overview tab select the Analytics button
- Under the table traces execute a query
| where customDimensions.Role == “CM” and severityLevel == 3
- The results will not be ordered properly, make sure you click the column header for timestamp to order by date
- Application insights has some handy auto-complete features to help you build a custom query to get exactly the data you’re looking for
NOTEWhile Application insights provides a good way to track and query log data, there does seem to be particular cases where the application does not properly submit log data to Application Insights. This leads us to the next Method.
A more root level logging solution is the log streaming option offered by the App Service. This can provide a more reliable but less pleasant source of logs, this is good if you have an easily reproducible scenario. This will provide appropriate data in a more traditional format that many Sitecore developers will be more comfortable with. This option can give you more accurate and complete logging. It is important to note however that the logs get placed on the filesystem, so that will effect your filesystem size.
- Open the Diagnostics logs tab and turn on all the streaming logs settings.
- In the log stream you will now see logs coming in at real time
Some IIS level events and errors will find their way into the underlying filesystem, you can use Kudu to access them.
- First you need to access Kudu
- Using either the cmd or powershell Debug console navigate to D:\home\LogFiles and open eventlog.xml
- Here you will find IIS events and errors that may uncover more catastrophic errors that fail to be recorded in Application Insights
Azure App Service Logging
Sometimes despite all other options the problem persists, this is when we must view Azure health as on occasion without notification Azure events will impact our environments negatively.
- On the App Service select the Diagnose and solve problems tab
- There are several reports in this interface that are definately worth an in depth look. I’ll focus on the Web App Restarted report.
If you find that your app pool seems to be recycling too often, this is probably where you need to look.
- This report will give you any reason that Azure will have restarted your App Service