protected static SerilogConfiguration CreateConfig(out ISerilogConfigurationProviderCollection collection)
        {
            var config = new SerilogConfiguration();

            collection = config;
            return(config);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes new instance of <see cref="SerilogConfigurationSource"/>.
        /// </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 SerilogConfigurationSource(ISerilogConfigurationProviderCollection 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, ISerilogConfigurationProviderCollection configuration, params string[] parentPath)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(builder.Add(new SerilogConfigurationSource(configuration, parentPath)));
        }