Implementing a Custom ILogger with Exception Handling for .NET Core

,

This article corresponds with the MSDN article: Essential .NET – Logging with .NET Core. This github repo contains the code referenced in the article. Not in particular the unit test LogCritical_Exception_Success for an example of handling an exception using the custom logger.

The Custom Logger implementation is straightforward:

Here is the the extension method for adding a custom logger provider:

The custom logger provider:

The provider event args

One uses the ApplicationLogging static class to set up the custom logger with the following pattern

2 responses to “Implementing a Custom ILogger with Exception Handling for .NET Core

Leave a Reply

Your email address will not be published. Required fields are marked *