Serilog
Neos uses Serilog as logging library. By default, messages are written in the console and optionally in Application Insights.
If you need to see internal commands executed during the database migration, you can follow this specific guide.
Serilog configuration is read in configuration in the default Serilog section.
The default configuration in our appsetttings.json looks like this in development mode:
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Hosting.Diagnostics": "Error",
"Yarp.ReverseProxy.Forwarder.HttpForwarder": "Error",
"Microsoft.AspNetCore": "Warning",
"Yarp": "Warning",
"Finbuckle": "Warning",
"GroupeIsa.Neos.ServerProxy.MultiTenant": "Warning"
}
}
}
}
Note
Available values for log levels are :
Verbose: This is the lowest level and will log everything. It's typically used for tracing and can be very detailed.Debug: This level is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened.Information: This level is used to track the general flow of the application.Warning: This level is used for events that could potentially cause issues.Error: This level is used to log errors and exceptions that occur in the application.Fatal: This level is used to log critical errors that result in the termination of the application.
You can override the default logging levels with environment variables.
For example, if you want information messages from Microsoft namespace, you can create the following environment variable (example in PowerShell):
${env:Serilog__MinimumLevel__Override__Microsoft} = "Information"
Custom output template
If you want to configure a specific output template, you can define it as a value of the OutputTemplate property under the Serilog section of your application configuration.
Example :
{
"Serilog": {
"OutputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
}
Note
Default output template is {Timestamp:HH:mm:ss} {Level:u3} {SourceContext} - {Message}{NewLine}{Exception}.
Note
When a WriteTo:Console sink is also declared in configuration alongside Serilog:OutputTemplate, Neos replaces it with a single programmatic Console sink that applies the custom template. Any restrictedToMinimumLevel set on the config WriteTo:Console sink is preserved: the programmatic replacement uses the most permissive (lowest) level declared across all config Console sinks.
Important
Custom output templates are only available in production environments. In development mode, the server proxy overrides the output template to separate logs from different services (report server, proxy, backend, etc.).
Entity Framework Core
Currently, only information, warning and error logs sent by EF Core are forwarded to Serilog.
All logs emitted by EF Core are in namespaces nested in Microsoft.EntityFrameworkCore namespace but as our default configuration filters logs from the Microsoft namespace at the 'Warning' level, information logs from EF Core will not appear by default.
To obtain the information-level logs issued by EF Core, you can create the following environment variable (example in PowerShell):
${env:Serilog__MinimumLevel__Override__Microsoft.EntityFrameworkCore} = "Information"
To customize logs emitted by EF Core, you can use EFCoreWarnings in cluster configuration.
Default log level on neos command
The neos command provides a directive for setting the default minimum log level.
Example to set the default level to debug on a setup command:
neos [log:debug] setup
The allowed values are verbose, debug, information, warning, error and fatal.
Note
The previous example is equivalent to setting the following environment variable (example in PowerShell):
${env:Serilog__MinimumLevel} = "Debug"
Serilog expression
Every dotnet project in Neos ecosystem comes with the Serilog expressions package.
For example, when deploying Neos clusters using Neos Helm chart, dotnet applications configurations will have by default the healthcheck and metrics endpoints excluded from the Serilog logs :
"Serilog": {
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"Expression": "RequestPath = '/hc' and StatusCode=200"
}
},
{
"Name": "ByExcluding",
"Args": {
"Expression": "RequestPath = '/metrics' and StatusCode=200"
}
}
]
}
In this case, only non successful /hc and /metrics requests will be logged.
You can add your own expressions in the associated secrets (see this article for more details on deployment configuration).