Microsoft.Extensions.Logging.TraceSource 10.0.0-preview.5.25277.114

About

Implements a trace logger provider for the .NET logging infrastructre facilitating enhanced logging capabilities and trace-level diagnostics in application by writing messages to a trace listener using System.Diagnostic.TraceSource.

Key Features

  • Seamless integration with .NET logging infrastructure.
  • Fine-grained control over trace messages using SourceSwitch.
  • A set of builder methods to configure logging infrastructure.

How to Use

The Microsoft.Extensions.Logging.TraceSource library provides extension methods to the logger factory and the logger builder to add a trace source with trace listeners.

using System.Diagnostics;
using Microsoft.Extensions.Logging;

using var consoleTraceListener = new ConsoleTraceListener();
using var textWriterTraceListener = new TextWriterTraceListener("/traces.txt");
using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder
        .AddTraceSource(new SourceSwitch("Something") { Level = SourceLevels.All }, consoleTraceListener)
        .AddTraceSource(new SourceSwitch("HouseKeeping") { Level = SourceLevels.All }, textWriterTraceListener);
});

var logger = loggerFactory.CreateLogger<Program>();

logger.LogInformation("Information message.");
// Program Information: 0 : Information message.
logger.LogWarning("Warning message.");
// Program Warning: 0 : Warning message.

var traceSource = new TraceSource("HouseKeeping", SourceLevels.All);
traceSource.Listeners.Add(consoleTraceListener);
traceSource.Listeners.Add(textWriterTraceListener);

traceSource.TraceEvent(TraceEventType.Error, 0, "Error message.");
//HouseKeeping Error: 0 : Error message.

Main Types

The main types provided by this library are:

  • Microsoft.Extensions.Logging.TraceSource.TraceSourceLoggerProvider

Additional Documentation

Feedback & Contributing

Microsoft.Extensions.Logging.TraceSource is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Extensions.Logging.TraceSource.

Packages Downloads
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
56
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
52
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
51
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download. This package was built from the source at: https://github.com/aspnet/Universe/tree/244e037a222a7cd0a17feafb7f3a625fde40de97
51
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
50
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
49
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
49
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
48
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
47
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
47
Microsoft.AspNetCore.All
Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.
46
Microsoft.AspNetCore.All
Microsoft.AspNetCore.All
46

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET Standard 2.0

.NET 10.0

.NET 9.0

.NET 8.0

Version Downloads Last updated
10.0.0-preview.5.25277.114 4 06/12/2025
10.0.0-preview.4.25258.110 7 05/15/2025
10.0.0-preview.3.25171.5 15 04/12/2025
10.0.0-preview.2.25163.2 19 03/23/2025
10.0.0-preview.1.25080.5 19 03/01/2025
9.0.7 0 07/08/2025
9.0.6 6 06/14/2025
9.0.5 8 05/16/2025
9.0.4 16 04/09/2025
9.0.3 19 03/14/2025
9.0.2 21 02/19/2025
9.0.1 23 01/18/2025
9.0.0 30 11/13/2024
9.0.0-rc.2.24473.5 24 10/21/2024
9.0.0-rc.1.24431.7 31 09/17/2024
9.0.0-preview.7.24405.7 34 08/14/2024
9.0.0-preview.6.24327.7 32 07/23/2024
9.0.0-preview.5.24306.7 36 06/15/2024
9.0.0-preview.4.24266.19 31 06/01/2024
9.0.0-preview.3.24172.9 32 04/11/2024
9.0.0-preview.2.24128.5 33 03/23/2024
9.0.0-preview.1.24080.9 31 03/08/2024
8.0.1 26 10/08/2024
8.0.0 39 11/16/2023
8.0.0-rc.2.23479.6 29 10/21/2023
8.0.0-rc.1.23419.4 30 09/14/2023
8.0.0-preview.7.23375.6 32 08/25/2023
8.0.0-preview.6.23329.7 35 07/24/2023
8.0.0-preview.5.23280.8 33 06/28/2023
8.0.0-preview.4.23259.5 35 07/20/2023
8.0.0-preview.3.23174.8 40 07/25/2023
8.0.0-preview.2.23128.3 32 05/01/2023
8.0.0-preview.1.23110.8 34 07/20/2023
7.0.0 36 08/11/2023
7.0.0-rc.2.22472.3 35 07/21/2023
7.0.0-rc.1.22426.10 36 08/17/2023
7.0.0-preview.7.22375.6 35 06/04/2023
7.0.0-preview.6.22324.4 32 07/21/2023
7.0.0-preview.5.22301.12 38 05/04/2023
7.0.0-preview.4.22229.4 45 07/19/2023
7.0.0-preview.3.22175.4 36 07/25/2023
7.0.0-preview.2.22152.2 36 06/01/2023
7.0.0-preview.1.22076.8 35 08/17/2023
6.0.2-mauipre.1.22102.15 31 07/20/2023
6.0.2-mauipre.1.22054.8 33 07/17/2023
6.0.1 23 11/13/2024
6.0.0 39 06/20/2023
6.0.0-rc.2.21480.5 31 07/22/2023
6.0.0-rc.1.21451.13 37 07/26/2023
6.0.0-preview.7.21377.19 31 07/22/2023
6.0.0-preview.6.21352.12 31 07/22/2023
6.0.0-preview.5.21301.5 32 07/25/2023
6.0.0-preview.4.21253.7 31 07/22/2023
6.0.0-preview.3.21201.4 32 07/24/2023
6.0.0-preview.2.21154.6 38 08/02/2023
6.0.0-preview.1.21102.12 40 07/21/2023
5.0.0 37 07/15/2023
5.0.0-rc.2.20475.5 33 07/23/2023
5.0.0-rc.1.20451.14 32 07/23/2023
5.0.0-preview.8.20407.11 37 08/04/2023
5.0.0-preview.7.20364.11 41 07/22/2023
5.0.0-preview.6.20305.6 41 07/21/2023
5.0.0-preview.5.20278.1 39 07/22/2023
5.0.0-preview.4.20251.6 41 07/20/2023
5.0.0-preview.3.20215.2 43 07/22/2023
5.0.0-preview.2.20160.3 35 07/22/2023
5.0.0-preview.1.20120.4 38 07/21/2023
3.1.32 36 07/22/2023
3.1.31 37 07/25/2023
3.1.30 37 07/15/2023
3.1.29 37 08/06/2023
3.1.28 39 07/26/2023
3.1.27 44 07/21/2023
3.1.26 39 08/08/2023
3.1.25 48 05/30/2023
3.1.24 40 07/13/2023
3.1.23 44 06/04/2023
3.1.22 33 08/06/2023
3.1.21 35 07/22/2023
3.1.20 39 07/21/2023
3.1.19 37 08/12/2023
3.1.18 43 07/20/2023
3.1.17 43 07/21/2023
3.1.16 38 08/08/2023
3.1.15 45 06/22/2023
3.1.14 35 06/03/2023
3.1.13 44 07/18/2023
3.1.12 49 07/22/2023
3.1.11 40 07/21/2023
3.1.10 45 07/24/2023
3.1.9 39 07/20/2023
3.1.8 43 07/18/2023
3.1.7 40 07/21/2023
3.1.6 35 07/21/2023
3.1.5 39 06/17/2023
3.1.4 42 06/05/2023
3.1.3 34 06/05/2023
3.1.2 38 07/25/2023
3.1.1 42 07/17/2023
3.1.0 42 07/01/2023
3.1.0-preview3.19553.2 39 07/25/2023
3.1.0-preview2.19525.4 33 07/22/2023
3.1.0-preview1.19506.1 35 07/22/2023
3.0.3 37 06/21/2023
3.0.2 37 06/07/2023
3.0.1 39 05/24/2023
3.0.0 42 06/17/2023
3.0.0-rc1.19456.10 39 07/22/2023
3.0.0-preview9.19423.4 34 07/25/2023
3.0.0-preview8.19405.4 35 07/21/2023
3.0.0-preview7.19362.4 38 07/22/2023
3.0.0-preview6.19304.6 38 08/03/2023
3.0.0-preview5.19227.9 33 07/18/2023
3.0.0-preview4.19216.2 35 07/22/2023
3.0.0-preview3.19153.1 31 07/22/2023
3.0.0-preview.19074.2 35 07/22/2023
3.0.0-preview.18572.1 34 07/21/2023
2.2.0 40 06/25/2023
2.2.0-preview3-35497 37 06/08/2023
2.2.0-preview2-35157 35 09/23/2023
2.2.0-preview1-35029 42 06/29/2023
2.1.1 38 06/07/2022
2.1.0 39 05/28/2023
2.1.0-rc1-final 36 07/10/2023
2.1.0-preview2-final 32 07/24/2023
2.1.0-preview1-final 34 07/24/2023
2.0.2 38 07/21/2023
2.0.1 44 08/12/2023
2.0.0 40 06/21/2023
2.0.0-preview2-final 50 07/22/2023
2.0.0-preview1-final 43 06/14/2023
1.1.2 34 06/06/2023
1.1.1 38 08/10/2023
1.1.0 38 07/22/2023
1.1.0-preview1-final 38 07/25/2023
1.0.2 44 06/05/2023
1.0.1 46 06/05/2023
1.0.0 40 07/23/2023
1.0.0-rc2-final 37 08/06/2023
1.0.0-rc1-final 37 07/07/2023