This package provides a Microsoft.Extensions.Logging bridge for the platform, allowing diagnostic log messages produced by Microsoft.Testing.Platform and its extensions to flow through any Microsoft.Extensions.Logging provider (Console, Debug, Serilog, OpenTelemetry, Application Insights, ...). Microsoft Testing is a set of platform, framework and protocol intended to make it possible to run any test on any target or device.
Get Started
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
Microsoft.Testing.Extensions.Logging
Microsoft.Testing.Extensions.Logging is an extension for Microsoft.Testing.Platform that bridges the platform's logging pipeline with Microsoft.Extensions.Logging, so diagnostic messages produced by the platform and its extensions can flow through any Microsoft.Extensions.Logging provider — Console, Debug, Serilog, Application Insights, OpenTelemetry, custom sinks, and more.
Microsoft.Testing.Platform is open source. You can find Microsoft.Testing.Extensions.Logging code in the microsoft/testfx GitHub repository.
Install the package
dotnet add package Microsoft.Testing.Extensions.Logging
You will typically also add a Microsoft.Extensions.Logging provider package, e.g.:
dotnet add package Microsoft.Extensions.Logging.Console
Usage
using Microsoft.Extensions.Logging;
using Microsoft.Testing.Extensions;
using Microsoft.Testing.Platform.Builder;
ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args);
builder.AddMicrosoftExtensionsLogging(logging =>
{
logging.AddConsole();
logging.AddDebug();
});
using ITestApplication app = await builder.BuildAsync();
return await app.RunAsync();
About
This package extends Microsoft.Testing.Platform with:
- Bridge to
Microsoft.Extensions.Logging: any MTP diagnostic log message is forwarded to the configuredMicrosoft.Extensions.Loggingproviders in addition to the platform's built-in--diagnosticfile logger. - Reuse existing logging stacks: plug Serilog, OpenTelemetry logs, Application Insights, or your own custom
ILoggerProviderinto the testing platform without writing a custom MTP logger provider.
The bridge maps Microsoft.Testing.Platform.Logging.LogLevel to Microsoft.Extensions.Logging.LogLevel, forwards the same state, exception, and formatter through to Microsoft.Extensions.Logging.ILogger.Log, and respects per-category filter rules defined in the ILoggingBuilder.
Notes and limitations
EventIdis not propagated. Microsoft.Testing.Platform'sILoggerhas no notion ofEventId; every forwarded log entry is written withEventId.None. Consumers that rely onEventId-based filtering downstream of the bridge will not see distinct IDs.- MTP does not create logging scopes. The bridge does not synthesize or translate
BeginScopeoperations because Microsoft.Testing.Platform's logging contract has no scope API. Ambient scopes created by the caller may still be observed by its providers, but they are not controlled by MTP. - Structured state is forwarded, not reconstructed. The original state and formatter are passed unchanged to the Microsoft.Extensions logger. Providers can retain structure that was present in the original MTP log entry, but the bridge cannot recover message-template properties from an entry that was already produced as a formatted string.
- Per-category filters can only narrow, never widen. The bridge initializes the
ILoggingBuilderwith the platform's effective diagnostic level, and the platform itself filters messages before they reach any provider. Setting a more verbose minimum level insideconfigurehas no effect. - No-op when
--diagnosticis off. When the platform's effectiveLogLevelisNone(the default), theconfiguredelegate is not invoked and noMicrosoft.Extensions.Logging.LoggerFactoryis created, so expensive sinks (network, file, gRPC) are not initialized for runs that will never emit a log. LogAsyncis forwarded synchronously.Microsoft.Extensions.Logginghas no async logging API;ILogger.LogAsynccallsILogger.Logdirectly and returnsTask.CompletedTask. The bridge does not block on asynchronous work, but a provider that performs blocking I/O still blocks the calling thread.- Owned vs. caller-owned factories. The
Action<ILoggingBuilder>overload creates and disposes its ownILoggerFactory. TheILoggerFactoryoverload never disposes the caller-supplied instance. - Registration is process-local. A supplied logger factory cannot cross a process boundary. Separately launched test host or controller processes must register their own bridge if their diagnostic logs need to reach the same external system.
Documentation
For comprehensive documentation, see https://aka.ms/testingplatform.
Feedback & contributing
Microsoft.Testing.Platform is an open source project. Provide feedback or report issues in the microsoft/testfx GitHub repository.
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.