如何更改 F# Saturn Framework 中的日志级别?

How to change log level in F# Saturn Framework?

当我 运行 我的 Saturn 应用程序时,我看到一些日志被写入控制台。

看起来他们是从 LogLevel.Info 开始的。我如何进行更详细的日志记录,即如何正确设置,例如LogLevel.Trace?

一种方法是将 logging 设置在土星 app builder:

let app = application {
    pipe_through endpointPipe

    router topRouter
    url "http://0.0.0.0:8085/"
    memory_cache
    use_static "static"
    use_gzip
    logging configureLogging
}

你可以这样配置:

let configureLogging (logging: ILoggingBuilder) =
    logging.SetMinimumLevel(LogLevel.Trace) |> ignore

我找到的唯一土星示例是 here, in the Saturn samples. There are more 用于 ASP.NET 核心,土星是在其之上构建的。

默认日志级别为indeed LogLevel.Info:

If you don't explicitly set the minimum level, the default value is Information, which means that Trace and Debug logs are ignored.

Remember 不为生产设置 LogLevel.Trace

These messages may contain sensitive application data. These messages are disabled by default and should never be enabled in a production environment.