asp.net-mvc – NLog在所有aspnet布局渲染器上抛出配置异常
发布时间:2020-12-15 18:33:53 所属栏目:asp.Net 来源:网络整理
导读:我一直在努力在我的ASP.NET MVC 3应用程序上设置NLog v2,迄今为止已经运行得很好。 (我正在使用官方nuGet存储库中的包)但是,当我尝试更改日志布局以包含任何aspnet- *布局渲染器时,我得到一个配置错误。我将问题减少到以下最低用例: 在configSections块
我一直在努力在我的ASP.NET MVC 3应用程序上设置NLog v2,迄今为止已经运行得很好。 (我正在使用官方nuGet存储库中的包)但是,当我尝试更改日志布局以包含任何aspnet- *布局渲染器时,我得到一个配置错误。我将问题减少到以下最低用例:
在configSections块中: <section name="nlog" type="NLog.Config.ConfigSectionHandler,NLog"/> Nlog块: <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> <variable name="logDirectory" value="C:Logs" /> <targets> <target name="logFile" xsi:type="File" fileName="${logDirectory}app.log" layout="${aspnet-user-identity}" /> </targets> <rules> <logger name="*" minlevel="Info" writeTo="logfile" /> </rules> 如果我改变布局,使用不属于aspnet *系列的任何渲染器的组合,这样做很好(我没有测试过,但是我已经看了很多)。我得到的错误在这里: Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: An error occurred creating the configuration section handler for nlog: Exception occurred when loading configuration from C:..[snip]..web.config Source Error: Line 16: </configSections> Line 17: Line 18: <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" Line 19: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> Line 20: 我真的不知道发生了什么。我不知道该渲染器会导致配置无效。我一直在大声喧哗,没有任何地方,所以我希望有人能帮忙。 谢谢! 解决方法
请确保您引用了NLog.Extended程序集,这些程序集定义了哪些布局,哪些必须由NuGet软件包添加到引用中:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> <extensions> <add assembly="NLog.Extended" /> </extensions> <variable name="logDirectory" value="C:Logs" /> <targets> <target name="logFile" xsi:type="File" fileName="${logDirectory}app.log" layout="${aspnet-user-identity} ${message}" /> </targets> <rules> <logger name="*" minlevel="Debug" writeTo="logfile" /> </rules> </nlog> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 可能在ASP.Net页面中引发404错误?
- asp.net-web-api – 默认请求标头不接受任何值,它始终为nul
- 如何在ASP.Net MVC中实现ReverseAJAX(Comet)
- asp.net-mvc – 如何将MEF与ASP.NET MVC 4和ASP.NET Web AP
- asp.net – 如何在生产.NET网站中更改Web引用?
- asp.net-mvc – 在ascx文件中使用Html.RenderPartial()
- 这应该是目前最快速有效的ASP.NET Core学习方式(视频)
- ASP.Net 3.5 / 4.0 CodeBehind还是CodeFile?
- asp.net-web-api – GlobalConfiguration – 尝试访问字段’
- asp.net mvc 下载文件并不打开下载页面
推荐文章
站长推荐
- asp.net-mvc-4 – ASP.NET Active Directory搜索
- asp.net – Microsoft Jet数据库引擎找不到对象’
- asp.net – 在同一站点上使用基本身份验证和表单
- asp.net – 在代码中设置PageSize时,DataPager停
- asp.net-mvc – 如何从自定义模型绑定器中删除魔
- asp.net-mvc – 在Owin Identity和Asp.Net MVC中
- ASP.NET EF实体主外键关系
- asp.net-mvc – 带数据注释的KendoUI网格默认值
- .net – 为所有操作调用ActionFilterAttribute
- 我可以通过编程方式从我的ASP.NET应用程序向IIS7
热点阅读