Enterprise library not logging severity correctly

时光毁灭记忆、已成空白 提交于 2019-12-01 11:24:31

问题


I have a problem with enterprise library 5. It's writing to the event log all the information I want it to write, however, it is not respecting the severity settings I configure.

My exception handling configuration block looks like this:

<exceptionHandlers>
  <add name="Logging Exception Handler"
       type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging...,"
       logCategory="General"
       eventId="10000"
       severity="Critical"
       title="My unknown error"
       formatterType="Micros...ExceptionFormatter, Micros...ExceptionHandling"
       priority="0" />
</exceptionHandlers>

My event log listener template starts with:

Severity: {severity}{newline}

The event log entry is logged as "Error", not "Critical", however the message that is actually logged contains the text "Severity: Critical"

Any pointers as to how I can actually log an exception as Critical without having to actually write my own exception handler/formatter?


回答1:


The behavior you are seeing is part of the .NET API.

There is no level or severity of Critical in the EventLogEntryType Enumeration which is used to log to the EventLog. TraceEventType, which is used by Enterprise Library as well as the .NET tracing infrastructure, does support a Critical severity.

However, inside the System.Diagnostics.EventLogTraceListener, which is used to log to the EventLog, a Critical TraceEventType is converted to an Error EventLogEntryType.

In the Event Viewer there is a filter for Critical but it seems that this level is reserved for low level errors. E.g. kernel related.



来源:https://stackoverflow.com/questions/8230601/enterprise-library-not-logging-severity-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!