问题描述
我正在尝试使用ASP.Net 5和MVC 6实现NLog日志记录.默认情况下,DNX 451和DNX Core 50都包含在项目模板中.
I am attempting to implement NLog logging using ASP.Net 5 and MVC 6. Be default, both DNX 451 and DNX Core 50 are included in the project template.
我正在尝试通过遵循示例这里.
I am attempting to implement NLog Logging by following the example here.
但是,在示例应用程序中,有以下一行-
However, in the sample app, there is the following line -
#if !DNXCORE50
factory.AddNLog(new global::NLog.LogFactory());
#endif
如果我运行该应用程序,则该行永远不会被击中,因为mvc应用程序默认情况下安装了dnx core 50.
And if I run the app, this line never gets hit because the mvc application has dnx core 50 installed by default.
DNX Core 50是否有可用的记录器?如果不是,那么dnx核心在默认的mvc应用程序中有什么作用-实际需要吗?
Is there any loggers that are available for DNX Core 50? If not, what purpose does dnx core serve in the default mvc app - is it actually needed?
如果删除上面的#if !DNXCORE50....
行,则会出现以下错误-
If I remove the #if !DNXCORE50....
line above, I get a the following error -
DNX Core 5.0 error - The type or namespace name 'NLog' could not be found in the global namespace'
推荐答案
仅当您想要云优化的.Net框架的跨平台版本时,才需要DNX Core 5.0.如果您仍然计划仅在Windows环境中使用MVC应用程序,则可以从project.json中删除dnxcore50
框架引用.
DNX Core 5.0 is only necessary if you want the cloud-optimized cross-platform version of the .Net framework; if you still plan on using the MVC app within only a Windows environment, you can remove your dnxcore50
framework reference from your project.json.
这篇关于NLog与DNX Core 5.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!