有没有办法通过 appSetting 配置来配置多个 Serilog RollingFiles [英] Is there a way to configure multiple Serilog RollingFiles through appSetting configuration

查看:58
本文介绍了有没有办法通过 appSetting 配置来配置多个 Serilog RollingFiles的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过 appSetting 配置多个 Serilog RollingFiles?

Is there a way to configure multiple Serilog RollingFiles through appSetting?

我想为信息和错误级别创建单独的日志文件.

I want to create separate log files for Information and Error levels.

推荐答案

不是直接 - 可以使用设置前缀,例如:

Not directly - it's possible to use a setting prefix like:

.ReadFrom.AppSettings()
.ReadFrom.AppSettings(settingPrefix: "2")

然后添加额外的接收器,如:

And then add the additional sink like:

<add key="2:serilog:write-to:RollingFile.pathFormat" value="..." />

将其正确地添加到应用设置配置提供程序中一直是待办事项"一段时间.

Baking this properly into the app settings configuration provider has been a "TODO" for a while.

如果可以在代码中配置接收器,那可能就是要走的路.

If configuring the sinks in code is possible, that's probably the way to go.

这篇关于有没有办法通过 appSetting 配置来配置多个 Serilog RollingFiles的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆