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

psf*_*aki 3 logging f# asp.net-core saturn-framework

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

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

psf*_*aki 6

一种方法是logging在 Saturn应用程序构建器中进行设置

let app = application {
    pipe_through endpointPipe

    router topRouter
    url "http://0.0.0.0:8085/"
    memory_cache
    use_static "static"
    use_gzip
    logging configureLogging
}
Run Code Online (Sandbox Code Playgroud)

你可以做这样的配置:

let configureLogging (logging: ILoggingBuilder) =
    logging.SetMinimumLevel(LogLevel.Trace) |> ignore
Run Code Online (Sandbox Code Playgroud)

我发现的唯一土星例子是这里,在土星样本中。ASP.NET Core有更多内容,Saturn 是在其之上构建的。

默认日志级别确实是 LogLevel.Info

如果未明确设置最低级别,则默认值为 Information,这意味着忽略 Trace 和 Debug 日志。

记住不要设置LogLevel.Trace为生产:

这些消息可能包含敏感的应用程序数据。这些消息在默认情况下是禁用的,不应在生产环境中启用。