【问题标题】:Is it possible to configure a Serilog Sub-logger from appSettings是否可以从 appSettings 配置 Serilog 子记录器
【发布时间】:2015-09-29 12:33:32
【问题描述】:

这就是我现在正在做的事情:

        Log.Logger = new LoggerConfiguration()
            .ReadFrom.AppSettings()
            .WriteTo.Logger(l => l.Filter.ByIncludingOnly(Matching.WithProperty("XXX")).WriteTo.File("output.txt"))
            .CreateLogger();

我在 app.config 中设置了我的主记录器,但我无法弄清楚在那里指定子记录器的语法。我真的很想避免混合代码和 appSettings 配置。

【问题讨论】:

    标签: serilog


    【解决方案1】:

    不,像现在这样使用 Serilog 是不可能的。

    【讨论】:

    • 更新:v2 将具有此功能,使用自定义设置前缀。 WriteTo.AppSettings(prefix: "sub") 将从键 "sub:serilog:..." 中读取,从而允许对子记录器进行唯一配置。
    • Nicholas,是否可以在 v2 中通过 AppSettings 添加子记录器?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    • 2019-03-30
    • 1970-01-01
    相关资源
    最近更新 更多