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.
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
EventSourceprovider writes to a cross-platform event source with the name
- 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.
maximum file sizeand
file namecan be specified while configuring this provider.
- Application Logging (Blob), if this option is enabled, a
storage accountneeds to be configured and
blob namecan be specified. All log messages would be written to the specified blob.
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.
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.
- elmah.io (GitHub repo)
- JSNLog (GitHub repo)
- Log4Net (GitHub repo)
- Loggr (GitHub repo)
- NLog (GitHub repo)
- Serilog (GitHub repo)
- Stackdriver (Github repo)
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.