-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed obsolete-attribute from ConfigureNLog-methods for ILoggingBuilder #482
Conversation
I'm doubting about this. Afaik it's still bad practice to use both? Nothing goes wrong but it's still obsolete IMO |
The ILoggerBuilder interface is not obsolete. And you are not required to use IHostBuilder. |
But it would be nice to have a better fluent-interface-integration with ILoggerBuilder and IHostBuilder to load the NLog-config-file depending on environment (Ex. Not everyone setup logging upfront before building the IHostBuilder (Ex want to load environment specific nlog.config). With NetCore3 you will have a lot of confused people that can no longer use ILoggerFactory. Instead a good alternative would be ILoggerBuilder. |
…lder. No longer generates double logging.
I believe it should be possible to setup NLog as LoggingProvider directly on LoggerFactory.Create: var loggerFactory = LoggerFactory.Create(builder =>
{
builder.ConfigureNLog("NLog.config");
});
ILogger logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Example log message"); And Microsoft recommends that logging is setup for IHostBuilder using IHostBuilder.ConfigureLogging: public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.ConfigureNLog("NLog.config");
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}); |
Ok merged! thanks! |
Reverting #257. Since it will no longer generate double logging after #459
Also fixed
ILoggingBuilder.ConfigureNLog()
-methods so they can work alone withoutIHostBuilder.UseNLog()
.See also: dotnet/AspNetCore.Docs#14554