在 .Net Core 中写入 EventLog [英] Write to EventLog in .Net Core

查看:36
本文介绍了在 .Net Core 中写入 EventLog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种在使用 dnx 的应用程序中写入 Windows 事件查看器的方法.但是,EventLog 类在 System.Diagnostics 命名空间中不可用,所以我被卡住了.还有其他方法可以写入 EventViewer 吗?

I need a way to write to Windows' event viewer in my app that's using dnx. But, the EventLog class isn't available in the System.Diagnostics namespace so I'm stuck. Is there any other way to write to the EventViewer?

推荐答案

Add from NuGet Microsoft.Extensions.Logging.EventLog Version 2.1.1

Add from NuGet Microsoft.Extensions.Logging.EventLog Version 2.1.1

CM> Install-Package Microsoft.Extensions.Logging.EventLog -Version 2.1.1

Program.cs 文件中包含命名空间 Microsoft.Extensions.Logging.EventLog

Include the namespace Microsoft.Extensions.Logging.EventLog in the Program.cs file

这解决了我的问题.

这篇关于在 .Net Core 中写入 EventLog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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