c# - 如何记录严重级别的事件日志?

标签 c# wpf event-log

我想将 EventViewer 中的条目记录为“关键”,但我没有关联的 EventLogType:

System.Diagnostics.EventLog.WriteEntry("ApplicationName", message, System.Diagnostics.EventLogEntryType.Error);

根据 MSDN,EventLogEntryType只有 5 个可能的值:

Error   
Warning 
FailureAudit
Information
SuccessAudit

在事件查看器中,有 5 个严重级别:

Critical
Error
Warning
Information
Verbose

但它没有映射! 错误日志中的错误 警告日志警告 但 FailureAudit、Information 和 SuccessAudit 日志记录在 Information

您知道如何使用 EventLog.WriteEvent 记录关键事件吗?

最佳答案

我相信它仅由系统本身生成:

Critical events are sent to the user in the form of an immediate message on the screen. Other event notifications are written to one of several event logs that record the information for future reference.

Source MSDN

关于c# - 如何记录严重级别的事件日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38746495/

相关文章:

c# - 除非特别触发,否则 XUnit 会忽略测试

c# - EF Code First,同一对象的两个导航属性

asp.net - Windows 事件日志权限

c# - 对象的 WPF 绑定(bind)列表到自定义控件

asp.net - 我需要更改什么才能允许IIS7 ASP.Net 3.5应用程序创建事件源并将事件记录到Windows EventLog?

powershell - 使用powershell创建事件日志条目并填写用户

c# - 为什么 DataRow 在方法的一部分中被识别而不是在另一部分中(我如何动态添加 DataRows)?

c# - 在 WPF 中。如何像iPhone一样通过鼠标拖动滚动ScrollViewer中的对象?

c# - 从 ViewModel 打开一个窗口窗体

c# - 如何将数据绑定(bind)到 DataGrid 中的 ComboBox?