带有 DNX Core 5.0 的 NLog [英] NLog with DNX Core 5.0

查看:23
本文介绍了带有 DNX Core 5.0 的 NLog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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.

我正在尝试通过以下示例来实现 NLog 日志记录 这里.

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'

推荐答案

DNX Core 5.0 仅当您想要 .Net 框架的云优化跨平台版本时才需要;如果您仍计划仅在 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.

这篇关于带有 DNX Core 5.0 的 NLog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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