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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Add from NuGet
Microsoft.Extensions.Logging.EventLog
Version 2.1.1
CM> Install-Package Microsoft.Extensions.Logging.EventLog -Version 2.1.1
Include the namespace Microsoft.Extensions.Logging.EventLog
in the Program.cs
file
This resolved my problem.
回答2:
Good news! EventLog is already ported to corefx and will be available in .NET Core 2.1.
Right now you can download a preview package System.Diagnostics.EventLog from their MyGet feed.
回答3:
it is available in 2.0 but you have to install the compatibility pack. https://github.com/dotnet/corefx/issues/25440
Here for more information: https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/