Created
October 11, 2021 13:16
-
-
Save rianjs/92db1dccf92e9714ae6094dc078964b9 to your computer and use it in GitHub Desktop.
GetLogger<T> using Microsoft.Extensions.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
private static ILogger<T> GetLogger<T>() | |
{ | |
using var loggerFactory = LoggerFactory.Create(builder => | |
{ | |
builder | |
.AddFilter("Microsoft", LogLevel.Warning) | |
.AddFilter("System", LogLevel.Warning) | |
.AddFilter("LoggingConsoleApp.Program", LogLevel.Debug) | |
.AddConsole(); | |
}); | |
var logger = loggerFactory.CreateLogger<T>(); | |
return logger; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment