@@ -47,6 +47,7 @@ public static LoggerConfiguration Configuration(
4747 DependencyContext dependencyContext = null )
4848 {
4949 if ( configuration == null ) throw new ArgumentNullException ( nameof ( configuration ) ) ;
50+
5051 return settingConfiguration . Settings (
5152 new ConfigurationReader (
5253 configuration ,
@@ -69,11 +70,63 @@ public static LoggerConfiguration ConfigurationSection(
6970 {
7071 if ( settingConfiguration == null ) throw new ArgumentNullException ( nameof ( settingConfiguration ) ) ;
7172 if ( configSection == null ) throw new ArgumentNullException ( nameof ( configSection ) ) ;
72-
73+
7374 return settingConfiguration . Settings (
7475 new ConfigurationReader (
7576 configSection ,
7677 dependencyContext ?? ( Assembly . GetEntryAssembly ( ) != null ? DependencyContext . Default : null ) ) ) ;
7778 }
79+
80+ /// <summary>
81+ /// Reads logger settings from the provided configuration object using the default section name. Generally this
82+ /// is preferable over the other method that takes a configuration section. Only this version will populate
83+ /// IConfiguration parameters on target methods.
84+ /// </summary>
85+ /// <param name="settingConfiguration">Logger setting configuration.</param>
86+ /// <param name="configuration">A configuration object which contains a Serilog section.</param>
87+ /// <param name="configurationAssemblySource">Defines how the package identifies assemblies to scan for sinks and other Types.</param>
88+ /// <returns>An object allowing configuration to continue.</returns>
89+ public static LoggerConfiguration Configuration (
90+ this LoggerSettingsConfiguration settingConfiguration ,
91+ IConfiguration configuration ,
92+ ConfigurationAssemblySource configurationAssemblySource )
93+ {
94+ if ( configuration == null ) throw new ArgumentNullException ( nameof ( configuration ) ) ;
95+
96+ if ( configurationAssemblySource == ConfigurationAssemblySource . UseLoadedAssemblies )
97+ {
98+ return Configuration ( settingConfiguration , configuration ) ;
99+ }
100+ else
101+ {
102+ return settingConfiguration . Settings ( new ConfigurationReader ( configuration , null ) ) ;
103+ }
104+ }
105+
106+ /// <summary>
107+ /// Reads logger settings from the provided configuration section. Generally it is preferable to use the other
108+ /// extension method that takes the full configuration object.
109+ /// </summary>
110+ /// <param name="settingConfiguration">Logger setting configuration.</param>
111+ /// <param name="configSection">The Serilog configuration section</param>
112+ /// <param name="configurationAssemblySource">Defines how the package identifies assemblies to scan for sinks and other Types.</param>
113+ /// <returns>An object allowing configuration to continue.</returns>
114+ public static LoggerConfiguration ConfigurationSection (
115+ this LoggerSettingsConfiguration settingConfiguration ,
116+ IConfigurationSection configSection ,
117+ ConfigurationAssemblySource configurationAssemblySource )
118+ {
119+ if ( settingConfiguration == null ) throw new ArgumentNullException ( nameof ( settingConfiguration ) ) ;
120+ if ( configSection == null ) throw new ArgumentNullException ( nameof ( configSection ) ) ;
121+
122+ if ( configurationAssemblySource == ConfigurationAssemblySource . UseLoadedAssemblies )
123+ {
124+ return Configuration ( settingConfiguration , configSection ) ;
125+ }
126+ else
127+ {
128+ return settingConfiguration . Settings ( new ConfigurationReader ( configSection , null ) ) ;
129+ }
130+ }
78131 }
79132}
0 commit comments