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
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | bool | false | Indicates 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
| Option | Type | Default | Description |
|---|---|---|---|
Enabled | bool | true in development, false in production | Enables simplified logging to the console. |
ShowQueries | bool | true | Indicates 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
| Option | Type | Default | Description |
|---|---|---|---|
AutoFlushLevel | LogLevel | None | Minimum level at which each message is directly visible in the file. None means Debug in DEBUG build, otherwise Error. |
DayToKeep | int | 2 | Number of days to keep trace files. |
Enabled | bool | true | Enables logging to a file. |
FolderPath | string | System temporary path | Folder containing log files. |
Format | LgFileLoggerFormat | IndentedJsonLines | Format of the log file. |
LogFilename | string | Solution name | Root name of the file in FolderPath. |
MaxFileSize | string | 5M | Maximum file size with unit K, M, or G. |
MaxFileSizeInByte | long | 5242880 | Maximum file size in bytes. |
ShowUser | bool | false | Logs the identifier of the connected user when available. |
ShowIpSource | bool | false | Logs the source IP address when available. |
File formats
| Value | Description |
|---|---|
IndentedJsonLines | Sequence of indented JSON objects, more readable for humans. |
JsonLines | JSON 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.