Introduction
If a problem occurs in your IoT Hub solution while running in production, you may want to enable diagnostic logs because that can help you diagnose the problem and fix it immediately. In this article, let us see how to enable diagnostic logs with an IoT Hub.
Please read the previous parts of the article before continuing with this one.
- How To Create Azure IoT Hub Using PowerShell
- How to Register IoT Device in Azure IoT Hub Using PowerShell
- How To Send Telemetry From An IoT Device To The Azure IoT Hub Using C#
Enable the diagnostic logs
When creating a new IoT Hub, the diagnostic logs are disabled by default. Let's see how to enable them.
-
Open your Azure portal and log in to your Azure account.
-
Select your IoT Hub from the resource groups.
-
Click "Diagnostic settings" in the Monitoring section. You can see the diagnostic status is disabled by default.
- Now, double click the resource. You can "Turn on diagnostics" like in the below image.
- Once you click the "Turn on diagnostics" link, the Diagnostic settings pane is displayed, as shown below.
-
Enter the name for your diagnostic setting. Here, I named it diags-hub.
-
Check "Archive to a storage account".
-
Click "Configure" to select the storage account screen.
-
Choose your storage account and click OK to return to the diagnostic settings pane.
To See the diagnostic logs
-
Go to your resource group and select your storage account, i.e., Hubflyiotstoragedev.
-
Select the Blobs from the Blob service, you can see the insight-logs-connections container.
-
Select the insight-logs-connections container. Drill down until you get the current date and choose the recent file.