Created
May 11, 2021 19:44
-
-
Save manoj-choudhari-git/757f9d88931620a11c41d800ac9df072 to your computer and use it in GitHub Desktop.
.NET Core Web Application - Customize Default Logging Providers for Web App
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
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateHostBuilder(args).Build().Run(); | |
} | |
public static IHostBuilder CreateHostBuilder(string[] args) => | |
Host.CreateDefaultBuilder(args) | |
.ConfigureWebHostDefaults(webBuilder => | |
{ | |
webBuilder.UseStartup<Startup>(); | |
webBuilder.ConfigureLogging((hostingContext, loggingBuilder) => | |
{ | |
loggingBuilder.ClearProviders(); | |
loggingBuilder.AddJsonConsole(options => | |
{ | |
options.IncludeScopes = false; | |
options.TimestampFormat = "hh:mm:ss "; | |
options.JsonWriterOptions = new JsonWriterOptions | |
{ | |
Indented = true | |
}; | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment