logging - 如何在 F# Saturn 框架中更改日志级别?
问题描述
当我运行我的 Saturn 应用程序时,我看到一些日志被写入控制台。
看起来他们以LogLevel.Info
. 如何进行更详细的日志记录,即如何正确设置 eg LogLevel.Trace
?
解决方案
一种方法是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
}
你可以像这样进行配置:
let configureLogging (logging: ILoggingBuilder) =
logging.SetMinimumLevel(LogLevel.Trace) |> ignore
我发现的唯一土星例子是here,在土星样本中。ASP.NET Core还有更多,在其之上构建了 Saturn。
默认日志级别确实是 LogLevel.Info
:
如果您没有明确设置最低级别,则默认值为 Information,即忽略 Trace 和 Debug 日志。
切记不要设置LogLevel.Trace
为生产:
这些消息可能包含敏感的应用程序数据。这些消息在默认情况下被禁用,不应在生产环境中启用。
推荐阅读
- c# - 我怎样才能使 ui 文本出现在其他任何内容之前?
- android - Android如何将顶部actionBar的标题居中?
- google-apps-script - Google 文档 setHeadingAttributes() 无法正常工作
- swift - 无法将“UITableViewCell”类型的值转换为“NSIndexPath”
- mysql - Apache Spark:如何仅从数据库中提取常见记录到集群
- bash - 在 bash 中重复使用标准输入
- python - PyCharm中关键词的不同颜色文本?
- c++ - 如何在 C++ 中删除动态数组的列
- swift - 如何在 swift 中创建自己的代码完成描述
- flutter - Flutter:当倒数计时器达到 0 时执行动作