protected static LoggingConfiguration CreateConfig(out ILoggingConfigurationProviderCollection collection) { var config = new LoggingConfiguration(); collection = config; return(config); }
/// <summary> /// Initializes new instance of <see cref="LoggingConfigurationSource"/>. /// </summary> /// <param name="providerCollection">Logging configuration provider collection that newly created providers are going to be added in.</param> /// <param name="parentPath">Path to logging section.</param> public LoggingConfigurationSource(ILoggingConfigurationProviderCollection providerCollection, params string[] parentPath) { _providerCollection = providerCollection ?? throw new ArgumentNullException(nameof(providerCollection)); _parentPath = parentPath ?? throw new ArgumentNullException(nameof(parentPath)); if (_parentPath.Any(String.IsNullOrWhiteSpace)) { throw new ArgumentException("The segments of the parent path must be null nor empty."); } }
/// <summary> /// Adds logging configuration provider <paramref name="builder"/>. /// </summary> /// <param name="builder">Configuration builder the logging configuration to add to.</param> /// <param name="configuration">Logging configuration to add to the <paramref name="builder"/>.</param> /// <param name="parentPath">Path the the logging section.</param> /// <returns>An instance of <see cref="IConfigurationBuilder"/>.</returns> public static IConfigurationBuilder AddLoggingConfiguration(this IConfigurationBuilder builder, ILoggingConfigurationProviderCollection configuration, params string[] parentPath) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(builder.Add(new LoggingConfigurationSource(configuration, parentPath))); }