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

问题描述 投票:1回答:1

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

看起来他们从LogLevel.Info开始。如何使用更详细的日志记录,例如如何正确设置,例如LogLevel.Trace

logging asp.net-core f# saturn-framework
1个回答
3
投票

一个方法是在土星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。有一个用于ASP.NET Core的more,在此基础上构建了土星。

默认日志级别为indeed LogLevel.Info

如果未显式设置最低级别,则默认值为“信息”,这意味着将忽略“跟踪”和“调试”日志。

Remember不要将LogLevel.Trace设置为生产:

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

© www.soinside.com 2019 - 2024. All rights reserved.