Microsoft Testing is a set of platform, framework and protocol intended to make it possible to run any test on any target or device. 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, ...).
Install
| 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.- 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.LogAsyncis forwarded toILogger.Logand returnsTask.CompletedTask.- Owned vs. caller-owned factories. The
Action<ILoggingBuilder>overload creates and disposes its ownILoggerFactory. TheILoggerFactoryoverload never disposes the caller-supplied instance.
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.
Changes from Previous Version
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.