Skip to content

Application settings

FantasticFiasco edited this page Apr 10, 2022 · 3 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.

HTTP sink

Parameter name CLR type JSON type JSON remarks JSON example
requestUri string string
queueLimitBytes long? number
logEventLimitBytes long? number
logEventsInBatchLimit int? number
batchSizeLimitBytes long? number
period TimeSpan? string See TimeSpan.Parse "00:00:02"
textFormatter ITextFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
batchFormatter IBatchFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
restrictedToMinimumLevel LogEventLevel string See Enum.Parse "Verbose"
httpClient IHttpClient? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
configuration IConfiguration? N/A Parameter cannot be set in JSON

Durable file size rolled HTTP sink

Parameter name CLR type JSON type JSON remarks JSON example
requestUri string string
bufferBaseFileName string string
bufferFileSizeLimitBytes long? number
bufferFileShared bool boolean
retainedBufferFileCountLimit int? number
logEventLimitBytes long? number
logEventsInBatchLimit int? number
batchSizeLimitBytes long? number
period TimeSpan? string See TimeSpan.Parse "00:00:02"
textFormatter ITextFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
batchFormatter IBatchFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
restrictedToMinimumLevel LogEventLevel string See Enum.Parse "Verbose"
httpClient IHttpClient string See Type.GetType "MyNamespace.MyClass, MyAssembly"
configuration IConfiguration? N/A Parameter cannot be set in JSON

Durable time rolled HTTP sink

Parameter name CLR type JSON type JSON remarks JSON example
requestUri string string
bufferBaseFileName string string
bufferRollingInterval BufferRollingInterval string See Enum.Parse "Day"
bufferFileSizeLimitBytes long? number
bufferFileShared bool boolean
retainedBufferFileCountLimit int? number
logEventLimitBytes long? number
logEventsInBatchLimit int? number
batchSizeLimitBytes long? number
period TimeSpan? string See TimeSpan.Parse "00:00:02"
textFormatter ITextFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
batchFormatter IBatchFormatter? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
restrictedToMinimumLevel LogEventLevel string See Enum.Parse "Verbose"
httpClient IHttpClient? string See Type.GetType "MyNamespace.MyClass, MyAssembly"
configuration IConfiguration? N/A Parameter cannot be set in JSON