Microsoft.Extensions.Logging.Abstractions
                               
                            
                                9.0.10
                            
                        
                            
                                
                                
                                    Prefix Reserved
                                
                            
                    See the version list below for details.
dotnet add package Microsoft.Extensions.Logging.Abstractions --version 9.0.10
NuGet\Install-Package Microsoft.Extensions.Logging.Abstractions -Version 9.0.10
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.10" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
paket add Microsoft.Extensions.Logging.Abstractions --version 9.0.10
#r "nuget: Microsoft.Extensions.Logging.Abstractions, 9.0.10"
#:package Microsoft.Extensions.Logging.Abstractions@9.0.10
#addin nuget:?package=Microsoft.Extensions.Logging.Abstractions&version=9.0.10
#tool nuget:?package=Microsoft.Extensions.Logging.Abstractions&version=9.0.10
About
Microsoft.Extensions.Logging.Abstractions provides abstractions of logging. Interfaces defined in this package are implemented by classes in Microsoft.Extensions.Logging and other logging packages.
This package includes a logging source generator that produces highly efficient and optimized code for logging message methods.
Key Features
- Define main logging abstraction interfaces like ILogger, ILoggerFactory, ILoggerProvider, etc.
How to Use
Custom logger provider implementation example
using Microsoft.Extensions.Logging;
public sealed class ColorConsoleLogger : ILogger
{
    private readonly string _name;
    private readonly Func<ColorConsoleLoggerConfiguration> _getCurrentConfig;
    public ColorConsoleLogger(
        string name,
        Func<ColorConsoleLoggerConfiguration> getCurrentConfig) =>
        (_name, _getCurrentConfig) = (name, getCurrentConfig);
    public IDisposable? BeginScope<TState>(TState state) where TState : notnull => default!;
    public bool IsEnabled(LogLevel logLevel) =>
        _getCurrentConfig().LogLevelToColorMap.ContainsKey(logLevel);
    public void Log<TState>(
        LogLevel logLevel,
        EventId eventId,
        TState state,
        Exception? exception,
        Func<TState, Exception?, string> formatter)
    {
        if (!IsEnabled(logLevel))
        {
            return;
        }
        ColorConsoleLoggerConfiguration config = _getCurrentConfig();
        if (config.EventId == 0 || config.EventId == eventId.Id)
        {
            ConsoleColor originalColor = Console.ForegroundColor;
            Console.ForegroundColor = config.LogLevelToColorMap[logLevel];
            Console.WriteLine($"[{eventId.Id,2}: {logLevel,-12}]");
            Console.ForegroundColor = originalColor;
            Console.Write($"     {_name} - ");
            Console.ForegroundColor = config.LogLevelToColorMap[logLevel];
            Console.Write($"{formatter(state, exception)}");
            Console.ForegroundColor = originalColor;
            Console.WriteLine();
        }
    }
}
Create logs
// Worker class that uses logger implementation of teh interface ILogger<T>
public sealed class Worker : BackgroundService
{
    private readonly ILogger<Worker> _logger;
    public Worker(ILogger<Worker> logger) =>
        _logger = logger;
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        while (!stoppingToken.IsCancellationRequested)
        {
            _logger.LogInformation("Worker running at: {time}", DateTimeOffset.UtcNow);
            await Task.Delay(1_000, stoppingToken);
        }
    }
}
Use source generator
public static partial class Log
{
    [LoggerMessage(
        EventId = 0,
        Level = LogLevel.Critical,
        Message = "Could not open socket to `{hostName}`")]
    public static partial void CouldNotOpenSocket(this ILogger logger, string hostName);
}
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);
}
Main Types
The main types provided by this library are:
- Microsoft.Extensions.Logging.ILogger
- Microsoft.Extensions.Logging.ILoggerProvider
- Microsoft.Extensions.Logging.ILoggerFactory
- Microsoft.Extensions.Logging.ILogger<TCategoryName>
- Microsoft.Extensions.Logging.LogLevel
- Microsoft.Extensions.Logging.Logger<T>
- Microsoft.Extensions.Logging.LoggerMessage
- Microsoft.Extensions.Logging.Abstractions.NullLogger
Additional Documentation
Related Packages
Microsoft.Extensions.Logging Microsoft.Extensions.Logging.Console Microsoft.Extensions.Logging.Debug Microsoft.Extensions.Logging.EventSource Microsoft.Extensions.Logging.EventLog Microsoft.Extensions.Logging.TraceSource
Feedback & Contributing
Microsoft.Extensions.Logging.Abstractions 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 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. | 
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. | 
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. | 
| MonoAndroid | monoandroid was computed. | 
| MonoMac | monomac was computed. | 
| MonoTouch | monotouch was computed. | 
| Tizen | tizen40 was computed. tizen60 was computed. | 
| Xamarin.iOS | xamarinios was computed. | 
| Xamarin.Mac | xamarinmac was computed. | 
| Xamarin.TVOS | xamarintvos was computed. | 
| Xamarin.WatchOS | xamarinwatchos was computed. | 
- 
                                                    .NETFramework 4.6.2- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- System.Buffers (>= 4.5.1)
- System.Diagnostics.DiagnosticSource (>= 9.0.10)
- System.Memory (>= 4.5.5)
 
- 
                                                    .NETStandard 2.0- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- System.Buffers (>= 4.5.1)
- System.Diagnostics.DiagnosticSource (>= 9.0.10)
- System.Memory (>= 4.5.5)
 
- 
                                                    net8.0- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.10)
- System.Diagnostics.DiagnosticSource (>= 9.0.10)
 
- 
                                                    net9.0
GitHub repositories (745)
Showing the top 20 popular GitHub repositories that depend on Microsoft.Extensions.Logging.Abstractions:
| Repository | Stars | 
|---|---|
| microsoft/PowerToys 
                                                            Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
                                                         | |
| jellyfin/jellyfin 
                                                            The Free Software Media System - Server Backend & API
                                                         | |
| 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.
                                                         | |
| ardalis/CleanArchitecture 
                                                            Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 9
                                                         | |
| 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+.
                                                         | |
| 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.
                                                         | |
| duplicati/duplicati 
                                                            Store securely encrypted backups in the cloud!
                                                         | |
| dotnet/AspNetCore.Docs 
                                                            Documentation for ASP.NET Core
                                                         | |
| chocolatey/choco 
                                                            Chocolatey - the package manager for Windows
                                                         | |
| dotnet/orleans 
                                                            Cloud Native application framework for .NET
                                                         | |
| HangfireIO/Hangfire 
                                                            An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
                                                         | |
| unoplatform/uno 
                                                            Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly.  Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
                                                         | |
| JeffreySu/WeiXinMPSDK 
                                                            微信全平台 .NET SDK, Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 8.0。已支持微信公众号、小程序、小游戏、微信支付、企业微信/企业号、开放平台、JSSDK、微信周边等全平台。 WeChat SDK for C#.
                                                         | |
| RayWangQvQ/BiliBiliToolPro 
                                                            B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。敏感肌也能用。
                                                         | |
| microsoft/ailab 
                                                            Experience, Learn and Code the latest breakthrough innovations with Microsoft AI
                                                         | |
| MassTransit/MassTransit 
                                                            Distributed Application Framework for .NET
                                                         | |
| elsa-workflows/elsa-core 
                                                            A .NET workflows library
                                                         | 
| Version | Downloads | Last Updated | 
|---|---|---|
| 10.0.0-rc.2.25466.103 | 0 | 9/22/2025 | 
| 10.0.0-rc.1.25451.107 | 1 | 9/22/2025 | 
| 10.0.0-rc.1.25421.113 | 0 | 8/28/2025 | 
| 10.0.0-preview.7.25380.108 | 0 | 8/11/2025 | 
| 10.0.0-preview.7.25380.105 | 0 | 8/6/2025 | 
| 10.0.0-preview.6.25358.103 | 0 | 7/17/2025 | 
| 10.0.0-preview.6.25321.102 | 0 | 6/25/2025 | 
| 10.0.0-preview.5.25280.105 | 0 | 6/2/2025 | 
| 10.0.0-preview.5.25277.114 | 0 | 6/3/2025 | 
| 10.0.0-preview.5.25277.101 | 0 | 5/29/2025 | 
| 10.0.0-preview.5.25266.103 | 0 | 5/20/2025 | 
| 10.0.0-preview.4.25255.103 | 0 | 5/12/2025 | 
| 9.0.10 | 2 | 9/23/2025 | 
| 9.0.7 | 22 | 7/11/2025 | 
| 3.0.0-preview.19074.2 | 14 | 1/28/2019 | 
| 3.0.0-preview.18572.1 | 2 | 11/30/2018 |