Logging and monitoring in Azure
In this section, we will talk about the logging and monitoring options in Azure.
Logging
The .NET Core app models, such as ASP.NET Core, support logging out-of-the-box. Logging can be enabled by injecting the ILoggerFactory
instance through the Configure
method of the Startup
class, and then using that to add providers. There are a few built-in providers available in the Microsoft.Extensions.Logging
namespace. For example, to log information at the Console level, we can call the AddConsole
method on the instance of LoggerFactory
or AddDebug
to log information in the Debug
window when the application is running under the debug mode.
Following is the list of logging provider's shipped with ASP.NET Core:
- Console
- Debug
- EventSource
- EventLog
- TraceSource
- Azure App Service
This is the sample code snippet to inject the logger factory instance on the Configure
method in the ASP.NET Core application:
public void Configure(IApplicationBuilder app, IHostingEnvironment env...