在我的应用程序中,我使用Enterprise库日志记录应用程序块来记录DB的异常。另外,我使用流畅的API来配置日志记录应用程序块。
我注意到的事情:
我的问题:
如有任何差异,请随时提出建议。 : - )
答案 0 :(得分:2)
确切的语法取决于您现有的配置。假设您没有配置要使用的跟踪侦听器或格式化程序:
configurationSourceBuilder
.ConfigureLogging()
.SpecialSources.LoggingErrorsAndWarningsCategory
.SendTo.EventLog("Event Log Listener")
.FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter"));
如果您已经配置了要使用的事件日志跟踪侦听器(在此示例中名为“Event Log Listener”):
configurationSourceBuilder
.ConfigureLogging()
.SpecialSources.LoggingErrorsAndWarningsCategory
.SendTo.SharedListenerNamed("Event Log Listener");
如果您已经配置了要使用的日志格式化程序(在此示例中名为“Text Formatter”):
configurationSourceBuilder
.ConfigureLogging()
.SpecialSources.LoggingErrorsAndWarningsCategory
.SendTo.EventLog("Event Log Listener")
.FormatWithSharedFormatter("Text Formatter");