Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created May 10, 2021 19:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/c41031fafd6197f52441597ffb94f305 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/c41031fafd6197f52441597ffb94f305 to your computer and use it in GitHub Desktop.
Non-Host Console Application - Configuring Logging
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