ASP.NET Core: How Log Filtering Works

The logging infrastructure of ASP.NET Core supports log filtering that is useful when we need one logging configuration for the development environment and the another for the live environment, for example. This blog post introduces log filtering in ASP.NET Core through simple dummy controller code samples.

In ASP.NET Core loggers have names. When we ask for the logger we also specify the name of the logger. The example below shows a dummy controller that accepts the logger factory as a constructor argument and asks for the logger names as “My Logger.”