public class HomeController : Controller { public IActionResult Index() { return View(); } }
public class SampleClass { private readonly ILoggerIn this example, the DoSomething() method on the SampleClass logs an informational message using ILogger when it is called. Package/Library: Microsoft.Extensions.Logging.Abstractions_logger; public SampleClass(ILogger logger) { _logger = logger; } public void DoSomething() { _logger.LogInformation("The DoSomething method was called."); // rest of method code goes here } }