Created
February 1, 2016 10:20
-
-
Save ddikman/acdc9169204d906e53d9 to your computer and use it in GitHub Desktop.
Serilog Json configuration reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoggerSettings : ILoggerSettings | |
{ | |
private readonly IConfigurationSection _configuration; | |
public LoggerSettings(IConfigurationSection configuration) | |
{ | |
_configuration = configuration; | |
} | |
public IEnumerable<KeyValuePair<string, string>> Configurations | |
{ | |
get | |
{ | |
foreach (var childSection in _configuration.GetChildren()) | |
{ | |
yield return new KeyValuePair<string, string>(childSection["key"], childSection["value"]); | |
} | |
} | |
} | |
public void Configure(LoggerConfiguration loggerConfiguration) | |
{ | |
loggerConfiguration.ReadFrom.KeyValuePairs(Configurations); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment