Indyco explorer ships with Console and File logging enabled by default.
The default configuration is as follows:
"Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Enrichers.ClientInfo" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Warning" } }, "Enrich": [ "FromLogContext" ], "WriteTo": { "Console": { "Name": "Console", "Args": { "OutputTemplate": "[{Timestamp:G}] [{Level}] [{SourceContext}] {Message:lj} {Exception}{NewLine}" } }, "File": { "Name": "Logger", "Args": { "configureLogger": { "WriteTo": [ { "Name": "File", "Args": { "path": "App_Data/logs/application-.log", "RollingInterval": "Day", "fileSizeLimitBytes": 1000000, "rollOnFileSizeLimit": true, "retainedFileCountLimit": 30, "shared": true, "OutputTemplate": "[{Timestamp:G}] [{Level}] [{SourceContext}] {Message:lj} {Exception}{NewLine}" } } ], "Filter": [ { "Name": "ByExcluding", "Args": { "expression": "StartsWith(SourceContext, 'Audit')" } } ] } } } }
Configuration via appsettings
You can customize the logging configuration by editing the default appsettings.json or by overriding specific values in the appsettings.Production.json. Read below to know what are the possible customizations.
Configuration via environment variables (docker)
To customize the logging configuration via environment variables you need to override the default values by defining variables as described in the official .NET documentation.
Here's an example of how to override some of those parameters via environment variables:
Serilog__MinimumLevel__Default = Debug Serilog__WriteTo__Console__Args__OutputTemplate = [{Timestamp:G}] [{Level}] [{SourceContext}] {Message:lj} {Exception}{NewLine} Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__path = App_Data/logs/application-.log Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__RollingInterval = Day Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__fileSizeLimitBytes = 1000000 Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__rollOnFileSizeLimit = true Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__retainedFileCountLimit = 30 Serilog__WriteTo__File__Args__configureLogger__WriteTo__0__Args__OutputTemplate = [{Timestamp:G}] [{Level}] [{SourceContext}] {Message:lj} {Exception}{NewLine}
Further customization
The main parameters that you can customize are:
path | the path, relative to the application root folder, where the logs will be saved |
RollingInterval | the interval used for rolling the logs. Can be set as: "Minute", "Hour", "Day", "Month", "Year", "Infinite" |
fileSizeLimitBytes | The approximate maximum size, in bytes, to which a log file will be allowed to grow |
rollOnFileSizeLimit | If true, a new file will be created when the file size limit is reached |
outputTemplate | A message template describing the format used to write to the sink. You can disable ip logging by removing the {ClientIP} section of the message (read more) |