如何在.NET Framework for Serilog中设置配置 [英] How to setup configuration in .NET Framework for Serilog

查看:324
本文介绍了如何在.NET Framework for Serilog中设置配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队只是将我们的ASP.NET解决方案之一从登录log4net迁移到了Serilog(使用iLogger)进行记录。我们的解决方案是.NET Framework 4.6。我可以在线查看Serilog配置文档以在代码中设置配置,并在appsettings.json中找到一些文档。我们有Web.config配置文件。我们以前的log4net配置完全驻留在csproj文件中。

Our team just moved one of our ASP.NET solutions from logging in log4net to Serilog (using iLogger) for logging. Our solution is .NET Framework 4.6. I can see Serilog configuration documentation online for setting up configuration in code as well as some documentation in appsettings.json. We have Web.config configuration files. Our old log4net configuration resided completely in the csproj files.

在.NET Framework(特别是Web.config或它自己的XML配置文件)中是否有用于Serilog及其接收器配置的地方?我们是否必须将配置放入代码中(当我们创建记录器对象时)?我们是否可以为我们拥有的特定控制器和型号指定配置,如果有,在哪里有文档?我知道我们可以为log4net中的特定组或控制器和模型指定log4net的位置,日志级别等,但是不确定如何为Serilog执行此操作。如果您有任何与此相关的链接,请指出正确的方向。谢谢。

Is there a place for configuration for Serilog and its sinks in .NET Framework (specifically in Web.config or its own XML configuration file)? Do we have to put the configuration into the code (when we create the logger object)? Can we specify the configuration for specific controllers and models we have, and, if so, where is there documentation? I know we could specify locations, log levels, etc. for log4net for specific groups or controllers and models in log4net, but unsure how to do that for Serilog. If you got links for any of this, please point me in the right direction. Thanks.

推荐答案

经过更多调查(我不敢相信我会早些错过),文档此处指出您可以编辑web.config文件。如果有人在寻找web.config的配置,就去了。

After more investigating (and I can't believe I missed this earlier), the documentation here states you can edit the web.config file. In case anyone is looking for the configuration for web.config, there you go.

这篇关于如何在.NET Framework for Serilog中设置配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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