public class MyClass { private readonly ILogger _logger; public MyClass(ILoggerIn this example, the ILogger interface is injected into the class constructor using dependency inversion. The class then logs information to the logger using the LogInformation method. In this case, we are using typed logging by passing the MyClass type to the ILogger interface. This allows us to group and filter log messages by the type of the class that generated them. The package library for ILogger is the Microsoft.Extensions.Logging package. It is part of the .NET Core framework and can be used in both ASP.NET Core and console applications.logger) { _logger = logger; } public void DoWork() { _logger.LogInformation("Doing work..."); // Do some work... _logger.LogInformation("Work is done."); } }