Configuration¶
Parameters can be configured within appsettings.json
of this application.
Configuration file example:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"System": "Warning",
"Microsoft": "Warning"
},
"Console": {
"FormatterName": "simple"
},
"ApplicationInsights": {
"LogLevel": {
"Default": "Information",
"System": "Error",
"Microsoft": "Error"
}
}
},
"DebugIndicators": "App,Detail,Onl",
"ApplicationInsights": {
"InstrumentationKey": null
},
"ConnectionStrings": {
"DbDataContextConnectionString": "Server=.;Database=FrontStage;Trusted_Connection=True;"
},
"DatabaseType": "MsSql",
"InstanceKey": 0,
"TempPath": "E:\\Atlantis\\SrecConvert"
}
Note
Part of the configuration can be separated into another file appsettings.ENVIRONMENT.json
, where ENVIRONMENT is the name of the environment, which can be specified using an environment variable named DOTNET_ENVIRONMENT
. This file is used during development and testing.
Logging section¶
It contains the default settings (subsection Logging:Loglevel
) and then a subsection for individual providers (where the LogLevel
structure is repeated). The providers Logging:Console
, Logging:Debug
, Logging:EventSource
, Logging:ApplicationInsights
and, when deployed on Windows, Logging:EventLog
are also considered. Logging in detail
Loglevel structure¶
The subsection usually contains a Default
area that indicates the default logging level for all areas. Specific fields can then be listed separately. The areas are set as FQDN C# classes by default. The possible levels are Trace, Debug, Information, Warning, Error, Critical
and None
.
Console provider¶
The most common provider, whose content is visible in the running application window if running as a console and in the Kubernetes log. The Logging:Console:FormatterName
parameter can be used to influence the format of the output, possible values are simple
, systemd
and json
. Formatting details
Debug provider¶
It can be used in Windows, which can be monitored using DbgView
, or in Linux, where it is written to files in the /var/log/syslog
or /var/log/message
folders.
ApplicationInsights section.¶
In .NET Core 6.0, it has only one parameter, ApplicationInsights:InstrumentationKey
, specifying the key to the ApplicationInsights
repository. AppInsights Configuration Details
ConnectionStrings section¶
In the ConnectionStrings section, there is a single parameter named ConnectionStrings:DbDataContextConnectionString
that contains the connection string to the database. For more info see Connectionstring.