在 app.config 中控制 serilog 的设置
Controlling settings for serilog in app.config
我需要使用 Serilog 以 Json 格式记录事件。我想使用 RollingFileSink。
根据以下 link,我们不能在 App.config 文件中指定 TextFormatter。
是否可以在 app.config 中指定所有其他配置,例如文件路径,然后在初始化记录器时将 textformatter 添加为代码中的 JsonFormatter?
只需使用普通设置即可,例如:
<add key="filePath" value="C:..." />
并且:
WriteTo.RollingFile(..., ConfigurationManager.AppSettings["filePath"])
我需要使用 Serilog 以 Json 格式记录事件。我想使用 RollingFileSink。
根据以下 link,我们不能在 App.config 文件中指定 TextFormatter。
是否可以在 app.config 中指定所有其他配置,例如文件路径,然后在初始化记录器时将 textformatter 添加为代码中的 JsonFormatter?
只需使用普通设置即可,例如:
<add key="filePath" value="C:..." />
并且:
WriteTo.RollingFile(..., ConfigurationManager.AppSettings["filePath"])