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

标签 logging asp.net-core 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 ,在土星样本中。有more对于 ASP.NET Core,在其之上构建了 Saturn。

默认日志级别为 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.

关于logging - 如何更改 F# Saturn Framework 中的日志级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51570112/

相关文章:

f# - 如何表达不变性保证

f# - 为什么 Seq.groupBy 不能像我认为的那样与列表一起工作? (F#)

c# - Elmah 日志错误页面自定义

logging - 在 Rust 中删除调试宏

c# - ASP.NET 核心 3.1 |如何使用服务集合进行单元测试并使用 NullLogger 作为 ILogger 实现

asp.net-core - 如何配置 ASP.Net TestHost 以便与 OpenId Connect 一起使用?

asp.net-core - 如何使用 ASP.NET Core 设置 EF6 迁移

python - 为什么附加到根记录器的过滤器不传播到后代记录器?

c# - NET CORE - AddScoped类,实现许多接口(interface),并通过接口(interface)类型获取它们

f# - 在 f# 中捕获打印语句