You are currently viewing Overview of Logging Providers Available In .NET

Overview of Logging Providers Available In .NET

In last few articles, we have seen how to configure logging in .NET applications. We mostly have used Console Provider, Debug Provider and JSON provider for logging. In this article, let’s have a quick overview different logging providers available.

There are several logging providers which come with .NET. They are generally referred to as Built-In providers. There are also many other third party implementations which can also be used with .NET applications. Let’s see some common options available.

Built-In Providers

There are many different types of built-in logging providers. There are basically two types of built-in providers

Shipped with Framework

These logging providers are shipped with .NET. When the general framework is installed, these logging providers are available. Most common providers as of today are:

  • Console – logs data to the console.
  • Debug – logs data to debug output window
  • EventSource – On Windows, the provider uses ETW. The EventSource provider writes to a cross-platform event source with the name Microsoft-Extensions-Logging
  • EventLog – this logs the messages in Windows Event Viewer.

Shipped by Microsoft via Nuget Packages

These set of logging providers are not shipped with .NET installer. These are shipped via NuGet packages by Microsoft.

Azure App Services

When an Azure App Service instance is created, there are two settings:

  • Application Logging (Filesystem), if this is enabled a file is written on file system of Azure app service. Retention period, maximum file size and file name can be specified while configuring this provider.
  • Application Logging (Blob), if this option is enabled, a storage account needs to be configured and blob name can be specified. All log messages would be written to the specified blob.

The Microsoft.Extensions.Logging.AzureAppServices provider package writes logs to text files in an Azure App Service app’s file system and to blob storage in an Azure Storage account.

Azure App Service and Application Logging Filesystem vs Application Logging Blob

Below code example shows the usage of AzureFileLoggerOptions and AzureBlobLoggerOptions for configuring logging providers.

Application Insights

Application insights is the semantic logging service by Azure. Application can send log messages to application insights using the special key, instrumentation key, which you get after creating this service instance in Azure. Application insights provide advanced tools to query and analyze the logs.

The Microsoft.Extensions.Logging.ApplicationInsights provider package writes logs to Azure Application Insights.

Third Party Providers

.NET logging implementation is completely based on a set of interfaces. These interfaces have been used by many third party companies / organizations to provide their own implementation.

Below are some of the logging providers. Full list can be viewed in .NET documentation.

Custom Providers

As mentioned earlier, third party providers implement the interfaces provided in .NET to provide their own logging provider. If the application needs, a custom implementation of logging provider can be created by using those interfaces. I will not cover the code here, maybe in future posts I will try to cover this topic.

Did you find this information helpful? Let me know your thoughts.

Leave a Reply