Skip to main content
Version: 2027 R1

Serilog section configuration

The Serilog section of the appsettings.json file defines which events are recorded in the Portal and Service logs and where they are written: to the database, to a file, to the console, or to the Windows Event Log.

danger

Make changes only in the appsettings.Production.json file. The appsettings.json file is overwritten during updates — see appsettings.json file configuration.

Section structure​

NodePurpose
UsingList of modules that provide log destinations (sinks) and enrichers.
MinimumLevelMinimum level of events recorded by the application.
WriteToLog destinations and their parameters.
EnrichAdditional information attached to every entry.

Default configuration from the appsettings.json template:

"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.MSSqlServer",
"Serilog.Sinks.File",
"Serilog.Enrichers.ClientInfo"
],
"MinimumLevel": {
"Default": "Warning"
},
"WriteTo": {
"ConsoleSink": "Console",
"MSSqlServerSink": {
"Name": "MSSqlServer",
"Args": {
"connectionString": "LogsDb",
"tableName": "Logs",
"schemaName": "infrastructure",
"autoCreateSqlTable": true,
"restrictedToMinimumLevel": "Warning",
"columnOptionsSection": {
"addStandardColumns": [ "LogEvent", "TraceId", "SpanId" ],
"removeStandardColumns": [ "Properties" ],
"id": { "nonClusteredIndex": true },
"level": { "storeAsEnum": false },
"timeStamp": { "convertToUtc": true },
"logEvent": {
"excludeAdditionalProperties": true,
"excludeStandardColumns": true
}
}
}
},
"FileSink": {
"Name": "File",
"Args": {
"path": "Logs/log-.txt",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}",
"restrictedToMinimumLevel": "Fatal"
}
}
},
"Enrich": [ "FromLogContext", "WithClientIp" ]
}

Logging levels​

Levels are used in the MinimumLevel and restrictedToMinimumLevel parameters. Events of the selected level and all higher levels are recorded.

LevelMeaning
VerboseThe most detailed diagnostic information. Produces a very large number of entries.
DebugInformation useful for troubleshooting.
InformationEvents describing normal application operation, e.g., startup.
WarningAbnormal situations that do not interrupt application operation. Default value.
ErrorErrors that prevented an operation from being completed.
FatalCritical errors after which the application cannot continue running.
caution

The Verbose, Debug, and Information levels significantly increase the number of entries, the server load, and the size of the log database. Use them temporarily, only while troubleshooting a problem.

Using​

List of modules used by the configuration. Every sink or enricher used in the WriteTo and Enrich nodes must have a corresponding module in this list.

ModuleProvides
Serilog.Sinks.ConsoleThe Console sink.
Serilog.Sinks.MSSqlServerThe MSSqlServer sink.
Serilog.Sinks.FileThe File sink.
Serilog.Sinks.EventLogThe EventLog sink — not included in the template; it must be added in appsettings.Production.json.
Serilog.Enrichers.ClientInfoThe WithClientIp enricher.
The list is merged by position

The Using list from appsettings.Production.json does not replace the list from the template; instead, it overrides it item by item. When specifying the list in appsettings.Production.json, repeat all modules from the template in the same order and append new modules at the end.

The Serilog.Sinks.OpenTelemetry module is also shipped with the application; the application uses it to export logs through OpenTelemetry. Modules of other sinks, e.g. Seq or Application Insights, are not shipped – you can send logs to these tools through an OpenTelemetry exporter or the Azure Application Insights section. A module that is not present in the installation directory cannot be used.

MinimumLevel​

ParameterTypeDefault valueDescription
DefaultlevelWarningGlobal minimum event level. Events of a lower level are skipped by all sinks, regardless of their restrictedToMinimumLevel setting – unless a different level is set for the given source in Override.
Override.<source>level— (not included in the template)Separate level for events from the selected source – higher or lower than Default, e.g., "Microsoft.AspNetCore": "Error" or "WebCon.WorkFlow.Module.Configuration": "Information". The source name is matched by prefix. WEBCON sources are listed on the Logging areas (loggers) page.

Example — detailed logs for a selected WEBCON area while keeping the Warning level for all other events:

"Serilog": {
"MinimumLevel": {
"Default": "Warning",
"Override": {
"WebCon.WorkFlow.Module.Configuration": "Information"
}
}
}

Example — temporarily enabling the Information level while limiting entries from platform components:

"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
}
}
tip

To also write Information events to the log database, additionally lower the restrictedToMinimumLevel value of the MSSqlServer sink — see MSSqlServer.

WriteTo​

The WriteTo node contains the log destinations (sinks). Each sink is an entry with an arbitrary, unique name (e.g., MSSqlServerSink, FileSink) that contains:

  • Name — the sink type (Console, MSSqlServer, File, EventLog),
  • Args — the sink parameters.

Thanks to named entries, in appsettings.Production.json you can change a single parameter of an existing sink (by referring to its name, e.g., FileSink) or add a new sink under a new name (e.g., EventLogSink).

Parameter common to all sinks:

ParameterTypeDescription
restrictedToMinimumLevellevelMinimum level of events recorded by the given sink. It works as an additional filter — it cannot lower the level defined in MinimumLevel.Default.

A sink defined in the template cannot be fully disabled through appsettings.Production.json. To effectively stop writing to it, set its restrictedToMinimumLevel to Fatal – the application very rarely records events at this level. Example for the logs database:

"Serilog": {
"WriteTo": {
"MSSqlServerSink": {
"Args": {
"restrictedToMinimumLevel": "Fatal"
}
}
}
}

Console​

Writes logs to the standard output of the application. In the template, it is defined in shorthand form as "ConsoleSink": "Console". Entries are visible only when the application is running in a console window.

MSSqlServer​

Writes logs to a SQL Server database. This is the primary log destination for the Portal and the Service — by default, events of level Warning and higher are written to the Infrastructure.Logs table in the configuration database. Each entry has a CorrelationID identifier (in versions earlier than 2026 R1: ErrorGuid).

The log table is optional — logging can be configured without it, using other sinks. In large environments, it is recommended to create a separate database for logs (specified in ConnectionStrings.LogsDb) or to use specialized log collection tools.

ParameterTypeDefault valueDescription
connectionStringtextLogsDbName of the connection string from the ConnectionStrings section (or a full connection string).
tableNametextLogsName of the table in which logs are stored.
schemaNametextinfrastructureSchema that contains the log table.
autoCreateSqlTabletrue / falsetrueAutomatically creates the log table at startup if it does not exist. Requires the account from the connection string to have permissions to create tables.
restrictedToMinimumLevellevelWarningMinimum level of events stored in the database.
columnOptionsSectionobjectsee belowSet of columns of the log table.

columnOptionsSection settings in the template:

ParameterValueDescription
addStandardColumnsLogEvent, TraceId, SpanIdAdditional columns: the full event in JSON format and the trace and span identifiers (they allow you to correlate a log entry with an OpenTelemetry trace).
removeStandardColumnsPropertiesColumns that are omitted.
id.nonClusteredIndextrueIndexing method of the identifier column.
level.storeAsEnumfalseThe level is stored as text (e.g., Warning) rather than as a number.
timeStamp.convertToUtctrueThe event time is stored in UTC.
logEvent.excludeAdditionalProperties, logEvent.excludeStandardColumnstrueLimits the content of the LogEvent column to data that is not present in the other columns.
caution

Do not change the tableName, schemaName, or columnOptionsSection parameters unless there is a clear need to do so. Changing the structure of the log table may cause tools that read logs to stop displaying them.

The log table is created by the sink on the first write when autoCreateSqlTable is set to true – it is not created by the installer or the database update. Set the value to false only when the table already exists.

Entries older than 30 days are deleted automatically by the Service during database maintenance hours. The retention period cannot be changed. Automatic cleanup and searching for errors by identifier in Designer Studio cover only the log table in the configuration database – if LogsDb points to a different database, you need to take care of removing old entries yourself.

File​

Writes logs to text files.

ParameterTypeDefault valueDescription
pathtextLogs/log-.txtFile path. A relative path is resolved against the working directory of the application. The date is appended to the file name, e.g., log-20261005.txt.
rollingIntervalvalue from listDayHow often a new file is created — see the table below.
outputTemplatetext{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}Format of a single entry: date and time, level abbreviation, message text, exception details.
restrictedToMinimumLevellevelFatalMinimum level of events written to the file. By default, only critical errors are written to the file.
retainedFileCountLimitnumber31 (not included in the template)Number of retained files. Older files are deleted.
fileSizeLimitBytesnumber (bytes)1 GB (not included in the template)Maximum size of a single file.
rollOnFileSizeLimittrue / falsefalse (not included in the template)When the size limit is reached, a new file is created instead of suspending writing.
rollingInterval valueNew file created
InfiniteNever — all entries in a single file.
YearEvery year.
MonthEvery month.
DayEvery day. Default value.
HourEvery hour.
MinuteEvery minute.

Example — writing events of level Error and higher to a file in an absolute directory, retaining 14 files:

"Serilog": {
"WriteTo": {
"FileSink": {
"Args": {
"path": "D:\\Logs\\WEBCON\\Portal\\log-.txt",
"restrictedToMinimumLevel": "Error",
"retainedFileCountLimit": 14
}
}
}
}

The account under which the application runs (the Portal application pool identity or the Service account) must have write permissions to the log directory.

Absolute path

There have been cases in which log files were not created when the default relative path was used. If writing to a file is important to you, specify an absolute path in path, as in the example above.

A relative path is resolved against the working directory of the process. For the Portal, this is the Portal installation directory, so files are created in its Logs subdirectory. The working directory of the Service, which runs as a Windows service, may be C:\Windows\System32 – so for the Service, specify an absolute path.

EventLog​

Writes logs to the Windows Event Log. This sink is not included in the template, and in new installations logs are not written to the Event Log, only to the database.

During an update from a version earlier than 2026 R1, the installer adds the EventLog sink to the appsettings.Production.json file so that — as in previous versions — events of level Warning and higher are written to the Event Log. If the log fills up with warnings, set "restrictedToMinimumLevel": "Error" in the sink or remove the sink from appsettings.Production.json (events will still be written to the database).

To enable writing to the Event Log yourself, add the Serilog.Sinks.EventLog module to the Using list and add a new entry in WriteTo:

"Serilog": {
"Using": [
"Serilog.Sinks.Console",
"Serilog.Sinks.MSSqlServer",
"Serilog.Sinks.File",
"Serilog.Enrichers.ClientInfo",
"Serilog.Sinks.EventLog"
],
"WriteTo": {
"EventLogSink": {
"Name": "EventLog",
"Args": {
"logName": "WebCon WorkFlow",
"source": "WorkFlow",
"restrictedToMinimumLevel": "Error"
}
}
}
}
ParameterTypeDescription
logNametextLog name. Entries are visible in Event Viewer under the Applications and Services Logs → <logName> node.
sourcetextEvent source displayed in the Source column.
restrictedToMinimumLevellevelMinimum level of events written to the log.
Event source registration

Creating a new log or event source requires administrator privileges. The application pool identity and the service account usually do not have them — if the source has not been registered beforehand, entries will not be written. The source can be registered once in PowerShell run as administrator:

New-EventLog -LogName "WebCon WorkFlow" -Source "WorkFlow"

Enrich​

List of enrichers, that is, information automatically attached to every entry.

ValueDescription
FromLogContextAttaches contextual information set by the application while processing a request or task – including the CorrelationId correlation identifier assigned to every request.
WithClientIpAttaches the client IP address. When the Portal runs behind a proxy server, obtaining the correct address requires configuring the Security section.

Regardless of this list, the application attaches a correlation identifier to entries (CorrelationId, also passed in the Correlation-ID HTTP header). It lets you find all entries related to a single request, also across different log destinations. HTTP request log entries additionally contain the signed-in user's login (User) and the request path including its parameters.