Azure provides built-in diagnostics to assist with debugging an App Service web app. The primary aim of this blog is to guide one step-by-step to add instrumentation to your application, as well as how to access the information logged.
Step 1:
Go to >App Service Logs> Enable Application Logging (Blob) and select the desired Blob Storage and the Container and select the Level of logging.
For more information on different types of logs you can refer this document.
Step 2:
Below is the code snippet of a .Net Core MVC web application we have deployed in a Windows App Service.
public IActionResult Index()
{
_logger.LogInformation("This is a test to send logs to : Blob ");
return View();
}
public IActionResult Privacy()
{
return View();
}
Below are different level of logs details which you can log:
Note: If you write logs to blobs, the retention policy no longer applies if you delete the app but keep the logs in the blobs. For more information, see Costs that might accrue after resource deletion. |
Step 3:
Go to Storage Account> Container and select the folder with your app service name and download the ( .txt ) file to check the logs.
The Blob option also includes additional information in the log messages, such as the ID of the origin VM instance of the log message (InstanceId), thread ID (Tid), and a more granular timestamp (EventTickCount) in a ( .csv ) file.
More information:
If you have any other questions, feel free to comment below!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.