Serilog settings

    Umbraco uses Serilog as its logging library, this means that the configuration of logging is offloaded to Serilog instead of the CMS. This means that logging specific configuration is not in the Umbraco.Cms section, but instead the Serilog section.

    We will go through some of the more common logging configurations here, but for more information see the Serilog settings github project.

    Default configuration

    When you create a new Umbraco project the following Serilog section will be included by default:

    "Serilog": {
      "MinimumLevel": {
        "Default": "Information",
        "Override": {
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information",
          "System": "Warning"
        }
      }
    }

    Specifying minimum log level

    As you can see above, the CMS comes with a default Serilog config that defines the minimum log level with the "MinimumLevel" key.

    You can specify the overall minimum log level with the "Default" key, this will apply to all namespaces, however it's also possible to override this log level for specific names spaces with the "Override" key. In the example above, any logging coming from the Microsoft and System namespaces will only log warnings and up, however the Microsoft.Hosting.Lifetime namespace will log information and up.

    The possible values, from most verbose to least, is:

    • Verbose
    • Debug
    • Information
    • Warning
    • Error
    • Fatal

    For information on what each of these levels means see the serilog wiki.

    Logging to a different output

    Serilog has the ability to log to a huge amount of different mechanism, from console, to files, even to slack or email, this is all configured using what Serilog calls sinks.

    An example of this can be seen in the default appsettings.Development.json, where Serilog is configured to log to the console using the Async wrapper sink:

      "Serilog": {
        "MinimumLevel": {
          "Default": "Information"
        },
        "WriteTo": [
          {
            "Name": "Async",
            "Args": {
              "configure": [
                {
                  "Name": "Console"
                }
              ]
            }
          }
        ]
      }

    Here you can see that we use the "WriteTo" key to specify a list of sinks the logger should write to. In this case we use the "Async" sink configured to write to the console, this means that we'll log to the console asynchronously.

    Now there's too many sinks to cover here, for a full list of all available sinks see Provided sinks. Each of these entries will have their own documentation on how to set up the logging with the particular sink.