So far, we have defined what to log in our application; in this section, we will illustrate how to do this. In ASP.NET Core, the logging provider is initialized using dependency injection. Moreover, it is possible to conditionally initialize it, depending on the environment or other startup options.
ASP.NET Core provides some built-in logging providers, as shown in the following table:
Providers | Namespace | Description |
Console | Microsoft.Extensions.Logging.Console |
Sets the console of the running application as the output of the logs.
|
Debug | Microsoft.Extensions.Logging.Debug |
Writes messages in the debug output window when a debugger is attached.
|
EventSource | Microsoft.Extensions.Logging.EventSource |
Sets the Windows ETW as the main log's output.
|
EventLog | Microsoft.Extensions.Logging.EventLog |
Sets the Windows event log as the main... |