![]() |
VOOZH | about |
dotnet add package Microsoft.Extensions.Logging --version 10.0.9
NuGet\Install-Package Microsoft.Extensions.Logging -Version 10.0.9
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.9" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.9" />Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.Logging" />Project file
paket add Microsoft.Extensions.Logging --version 10.0.9
#r "nuget: Microsoft.Extensions.Logging, 10.0.9"
#:package Microsoft.Extensions.Logging@10.0.9
#addin nuget:?package=Microsoft.Extensions.Logging&version=10.0.9Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.Logging&version=10.0.9Install as a Cake Tool
Microsoft.Extensions.Logging is combined with a core logging abstraction under Microsoft.Extensions.Logging.Abstractions. This abstraction is available in our basic built-in implementations like console, event log, and debug (Debug.WriteLine) logging.
Prior to .NET 6, we only had two forms possible for doing logging, using Microsoft.Extensions.Logging:
public class LoggingSample1
{
private ILogger _logger;
public LoggingSample1(ILogger logger)
{
_logger = logger;
}
public void LogMethod(string name)
{
_logger.LogInformation("Hello {name}", name);
}
}
Here are some problems with the LoggingSample1 sample using LogInformation, LogWarning, etc.:
Because of these problems, the more efficient runtime approach recommended as best practices is to use LoggerMessage.Define APIs instead, illustrated below with LoggingSample2:
public class LoggingSample2
{
private ILogger _logger;
public LoggingSample2(ILogger logger)
{
_logger = logger;
}
public void LogMethod(string name)
{
Log.LogName(_logger, name);
}
private static class Log
{
private static readonly Action<ILogger, string, Exception> _logName = LoggerMessage.Define<string>(LogLevel.Information, 0, @"Hello {name}");
public static void LogName(ILogger logger, string name)
{
_logName(logger, name, null!);
}
}
}
To reach a balance between performance and usability we added the compile-time logging source generator feature in .NET 6, to learn more about it and learn how to use a source generator to create log messages check out this documentation.
public partial class InstanceLoggingExample
{
private readonly ILogger _logger;
public InstanceLoggingExample(ILogger logger)
{
_logger = logger;
}
[LoggerMessage(
EventId = 0,
Level = LogLevel.Critical,
Message = "Could not open socket to `{hostName}`")]
public partial void CouldNotOpenSocket(string hostName);
}
ActivityTrackingOptions.NET 5.0 exposed a new feature that allows configuring the logger builder with the ActivityTrackingOption to add the tracing context Span Id, Trace Id, Parent Id, Trace state, and Trace flags to the logging scope. The tracing context usually carried in Activity.Current.
.NET 6.0 Preview 1 extended this feature to include more tracing context properties which are the Baggage and the Tags:
var loggerFactory = LoggerFactory.Create(logging =>
{
logging.Configure(options =>
{
options.ActivityTrackingOptions = ActivityTrackingOptions.Tags | ActivityTrackingOptions.Baggage;
}).AddSimpleConsole(options =>
{
options.IncludeScopes = true;
});
});
The main types provided by this library are:
Microsoft.Extensions.Logging.Abstractions Microsoft.Extensions.Logging.Console Microsoft.Extensions.Logging.Debug Microsoft.Extensions.Logging.EventSource Microsoft.Extensions.Logging.EventLog Microsoft.Extensions.Logging.TraceSource
Microsoft.Extensions.Logging is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Logging:
| Package | Downloads |
|---|---|
|
Microsoft.Extensions.Http
The HttpClient factory is a pattern for configuring and retrieving named HttpClients in a composable way. The HttpClient factory provides extensibility to plug in DelegatingHandlers that address cross-cutting concerns such as service location, load balancing, and reliability. The default HttpClient factory provides built-in diagnostics and logging and manages the lifetimes of connections in a performant way. Commonly Used Types: System.Net.Http.IHttpClientFactory |
|
|
Microsoft.EntityFrameworkCore
Entity Framework Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MySQL, PostgreSQL, and other databases through a provider plugin API. Commonly Used Types: Microsoft.EntityFrameworkCore.DbContext Microsoft.EntityFrameworkCore.DbSet |
|
|
Microsoft.Extensions.Logging.Configuration
Configuration support for Microsoft.Extensions.Logging. |
|
|
Microsoft.EntityFrameworkCore.Relational
Shared Entity Framework Core components for relational database providers. |
|
|
Microsoft.Extensions.Logging.Console
Console logger provider implementation for Microsoft.Extensions.Logging. |
Showing the top 20 popular GitHub repositories that depend on Microsoft.Extensions.Logging:
| Repository | Stars |
|---|---|
|
jellyfin/jellyfin
The Free Software Media System - Server Backend & API
|
|
|
files-community/Files
A modern file manager that helps users organize their files and folders.
|
|
|
DevToys-app/DevToys
A Swiss Army knife for developers.
|
|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
dotnet/maui
.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
|
|
|
dotnet/roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
|
|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 10
|
|
|
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
|
|
|
dotnet/efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
|
|
|
duplicati/duplicati
Store securely encrypted backups in the cloud!
|
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
|
App-vNext/Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
|
|
|
Sonarr/Sonarr
Smart PVR for newsgroup and bittorrent users.
|
|
|
babalae/better-genshin-impact
📦BetterGI · 更好的原神 - 自动拾取 | 自动剧情 | 全自动钓鱼(AI) | 全自动七圣召唤 | 自动伐木 | 自动刷本 | 自动采集/挖矿/锄地 | 一条龙 | 全连音游 | 自动烹饪 - UI Automation Testing Tools For Genshin Impact
|
|
|
Radarr/Radarr
Movie organizer/manager for usenet and torrent users.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
microsoft/garnet
Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, key migration, and replication features. Garnet can work with existing Redis clients.
|
|
|
chocolatey/choco
Chocolatey - the package manager for Windows
|
|
|
gui-cs/Terminal.Gui
Cross Platform Terminal UI toolkit for .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.5.26302.115 | 8,060 | 6/9/2026 |
| 11.0.0-preview.4.26230.115 | 40,197 | 5/12/2026 |
| 11.0.0-preview.3.26207.106 | 40,788 | 4/14/2026 |
| 11.0.0-preview.2.26159.112 | 59,292 | 3/10/2026 |
| 11.0.0-preview.1.26104.118 | 48,830 | 2/10/2026 |
| 10.0.9 | 2,050,680 | 6/9/2026 |
| 10.0.8 | 11,471,315 | 5/12/2026 |
| 10.0.7 | 15,206,895 | 4/21/2026 |
| 10.0.6 | 6,590,765 | 4/14/2026 |
| 10.0.5 | 19,490,467 | 3/12/2026 |
| 10.0.4 | 8,578,219 | 3/10/2026 |
| 10.0.3 | 22,559,897 | 2/10/2026 |
| 10.0.2 | 22,557,536 | 1/13/2026 |
| 10.0.1 | 21,715,191 | 12/9/2025 |
| 9.0.17 | 185,273 | 6/9/2026 |
| 9.0.16 | 952,288 | 5/12/2026 |
| 9.0.15 | 2,071,419 | 4/14/2026 |
| 9.0.14 | 2,629,005 | 3/10/2026 |
| 9.0.13 | 2,599,372 | 2/10/2026 |
| 9.0.12 | 3,797,446 | 1/13/2026 |