Learn about app logging provided by the Microsoft.Extensions.Logging NuGet package in C#.
Learn how to use the ASP.NET Core logging framework provided by the Microsoft.Extensions.Logging NuGet package.
Note Sometimes logging is also referred to as 'tracing', including in some of the older Windows and .NET APIs. In recent years, 'tracing' is more commonly used as an abbreviation for Distributed tracing, but that isn't the meaning in this article.
Logging providers persist logs, except for the Console provider, which only displays logs as standard output. For example, the Azure Application Insights provider stores logs in Azure Application Insights. Multiple providers can be enabled. The default .NET Worker app templates: Use the Generic Host. Call CreateApplicationBuilder, which adds the following logging providers: Console Debug ...
Learn how to use the LoggerMessageAttribute and compile-time source generation for logging in .NET.
Learn how to use source-generated logging with LoggerMessageAttribute to create high-performance logs with minimal overhead in .NET apps.
Log buffering works with all logging providers. If a logging provider you use does not implement the IBufferedLogger interface, log buffering will call log methods directly on each buffered log record when flushing the buffer. Log buffering extends filtering capabilities by allowing you to capture and store logs temporarily. Rather than making an immediate emit-or-discard decision, buffering ...
Learn how to expose logging as a library author in .NET. Follow the guidance to ensure your library is correctly exposed to consumers.
Learn how to use and implement custom console log formatting in your .NET apps. Register and create new log formatters for better application logging.