Created
May 10, 2021 19:45
-
-
Save manoj-choudhari-git/c41031fafd6197f52441597ffb94f305 to your computer and use it in GitHub Desktop.
Non-Host Console Application - Configuring 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using var loggerFactory = LoggerFactory.Create(builder => | |
{ | |
builder | |
.AddFilter("Microsoft", LogLevel.Warning) | |
.AddFilter("System", LogLevel.Warning) | |
.AddFilter("NonHostConsoleApp.Program", LogLevel.Debug) | |
.AddConsole(); | |
}); | |
ILogger logger = loggerFactory.CreateLogger<Program>(); | |
logger.LogInformation("Info Log"); | |
logger.LogWarning("Warning Log"); | |
logger.LogError("Error Log"); | |
logger.LogCritical("Critical Log"); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment