Skip to main content

Message Logging

Message logging is configured in the appsettings.json file of the Server project. Lagoon extends ASP.NET Core logging with a simplified console and a file logger.

Configuration example​

{
"Logging": {
"LogLevel": {
"Default": "Error"
}
},
"Lagoon": {
"DefaultLoggers": {
"Enabled": false
},
"LightConsoleLogger": {
"Enabled": true,
"ShowQueries": false
},
"FileLogger": {
"Enabled": true,
"LogFilename": "MonApp.txt",
"FolderPath": "C:\\Temp\\(Traces)",
"MaxFileSize": "5M",
"DayToKeep": 2,
"ShowUser": true
}
}
}

DefaultLoggers​

OptionTypeDefaultDescription
EnabledboolfalseIndicates whether the pre-registered logging handlers in the environment are kept, such as Console or EventLog.

When Lagoon:DefaultLoggers:Enabled is not true, Lagoon calls ClearProviders() then adds its loggers according to the configuration.

LightConsoleLogger​

OptionTypeDefaultDescription
Enabledbooltrue in development, false in productionEnables simplified logging to the console.
ShowQueriesbooltrueIndicates whether EF Core queries are logged to the console.
Notes

The simplified console displays application-specific messages, warnings, and errors. It is not activated when DefaultLoggers is enabled.

FileLogger​

OptionTypeDefaultDescription
AutoFlushLevelLogLevelNoneMinimum level at which each message is directly visible in the file. None means Debug in DEBUG build, otherwise Error.
DayToKeepint2Number of days to keep trace files.
EnabledbooltrueEnables logging to a file.
FolderPathstringSystem temporary pathFolder containing log files.
FormatLgFileLoggerFormatIndentedJsonLinesFormat of the log file.
LogFilenamestringSolution nameRoot name of the file in FolderPath.
MaxFileSizestring5MMaximum file size with unit K, M, or G.
MaxFileSizeInBytelong5242880Maximum file size in bytes.
ShowUserboolfalseLogs the identifier of the connected user when available.
ShowIpSourceboolfalseLogs the source IP address when available.

File formats​

ValueDescription
IndentedJsonLinesSequence of indented JSON objects, more readable for humans.
JsonLinesJSON Lines format: each line is a valid JSON value terminated by \n.

Viewing logs from the application​

The /lg/trace route allows displaying application traces for users authorized by the Policies.LogReader policy, whose value is log.read.