コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }