Skip to content

Application settings

Mykhailo Shevchuk edited this page Nov 29, 2020 · 11 revisions

The process of releasing software often starts with deployment to a staging environment, and after quality is assured the software is promoted to production. To minimize the risk of introducing new bugs one would like to promote the same binary, but with changes to the configuration. This means that configuration cannot be defined at compile-time, it must be applied at run-time. This is where the story of application settings begin.

The initiative from Microsoft to introduce Microsoft.Extensions.Configuration meant that other libraries, like Serilog, had a solid foundation to build their own configuration upon. This sink, in combination with Serilog.Settings.Configuration, supports application configuration by using Microsoft.Extensions.Configuration.Json or any other provider. The limited type system in JSON however forces us to write some of the configuration parameters in a slightly different way. The following chapters will list all configurable parameters and highlights those that in JSON have a different format than those defined in code.

Grafana Loki sink

Parameter name CLR type JSON type JSON remarks JSON example
uri string string
labels IEnumerable<LokiLabel> array of objects
filtrationMode LokiLabelFiltrationMode string See Enum.Parse "Include"
filtrationLabels IEnumerable<string> array of strings
credentials LokiCredentials object
outputTemplate string string
restrictedToMinimumLevel LogEventLevel string See Enum.Parse "Verbose"
batchPostingLimit int integer
queueLimit int integer
period TimeSpan string See TimeSpan.Parse "00:00:02"
textFormatter ITextFormatter string See Type.GetType "MyNamespace.MyClass, MyAssembly"
httpClient IHttpClient string See Type.GetType "MyNamespace.MyClass, MyAssembly"