serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
446 stars 129 forks source link

Add support for IFormatProvider used to convert string to other types #348

Closed 0xced closed 1 year ago

0xced commented 1 year ago

Also introduce a new ConfigurationReaderOptions class to avoid ReadFrom.Configuration() methods exponential growth when adding new options.

All older Configuration() methods go through the newly introduced Configuration(LoggerSettingsConfiguration, IConfiguration, ConfigurationReaderOptions) method that takes an ConfigurationReaderOptions instance.

Older methods explicitly set the FormatProvider option to null in order to preserve backward compatibility.

By using the new Configuration() method, users opt into the new default of having the invariant culture as the format provider.

Note: the = null default value in the Configuration() method taking a DependencyContext has been removed in order to make sure the CS0121 compilation does not occur:

[CS0121] The call is ambiguous between the following methods or properties: 'ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration, IConfiguration, DependencyContext)' and 'ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration, IConfiguration, ConfigurationReaderOptions)'

Fixes #325

nblumhardt commented 1 year ago

Awesome PR đź‘Ť