-
-
Save christiannagel/660aae44f6b8f4acfa2b6bda86f483d0 to your computer and use it in GitHub Desktop.
Configure TraceSource with .NET Core logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void RegisterServices(IConfiguration configuration) | |
{ | |
ConfigureTraceSourceLogging(); | |
var services = new ServiceCollection(); | |
services.AddLogging(builder => | |
{ | |
builder.AddConfiguration(configuration.GetSection("Logging")) | |
.AddTraceSource(new SourceSwitch("TraceSourceLog", SourceLevels.Verbose.ToString()), s_listener) | |
.AddConsole(); | |
#if DEBUG | |
builder.AddDebug(); | |
#endif | |
}); | |
services.AddHttpClient<SampleController>(); | |
AppServices = services.BuildServiceProvider(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment