private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serviceProvider, IConfiguration configuration, NLogProviderOptions options, LogFactory logFactory) { NLogLoggerProvider provider = new NLogLoggerProvider(options ?? NLogProviderOptions.Default, logFactory ?? LogManager.LogFactory); configuration = SetupConfiguration(serviceProvider, configuration); if (configuration != null && options == null) { provider.Configure(configuration.GetSection("Logging:NLog")); } return(provider); }
private static NLogLoggerProvider CreateNLogProvider(IConfiguration configuration) { var provider = new NLogLoggerProvider(new NLogProviderOptions()); if (configuration != null) { ConfigSettingLayoutRenderer.DefaultConfiguration = configuration; provider.Configure(configuration.GetSection("Logging:NLog")); } return(provider); }
private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serviceProvider, IConfiguration configuration, NLogProviderOptions options) { NLogLoggerProvider provider = new NLogLoggerProvider(options ?? NLogProviderOptions.Default); configuration = configuration ?? (serviceProvider?.GetService(typeof(IConfiguration)) as IConfiguration); if (configuration != null) { ConfigSettingLayoutRenderer.DefaultConfiguration = configuration; if (options == null) { provider.Configure(configuration.GetSection("Logging:NLog")); } } return(provider); }
private static NLogLoggerProvider CreateNLogLoggerProvider(IServiceProvider serviceProvider, IConfiguration configuration, NLogProviderOptions options, LogFactory logFactory) { NLogLoggerProvider provider = new NLogLoggerProvider(options ?? NLogProviderOptions.Default, logFactory ?? LogManager.LogFactory); configuration = SetupConfiguration(serviceProvider, configuration); if (serviceProvider != null && provider.Options.RegisterServiceProvider) { provider.LogFactory.ServiceRepository.RegisterService(typeof(IServiceProvider), serviceProvider); } if (configuration != null) { provider.Configure(configuration.GetSection("Logging:NLog")); provider.TryLoadConfigurationFromSection(configuration); } return(provider); }