0
votes

In my application I am using Enterprise library logging application block for logging exception to DB.Also, I am using fluent API to configure the logging application block.

Things I noticed:

  1. When I was not using the Fluent API and database logging fails it logged the exception to windows event log.(version 5.0)
  2. But when i used it(Fluent API), In case of database failure it is not logging exception anywhere not even in windown event log.

My Question:

  1. Is it a normal behavior of Enterprise library logging application block?
  2. Is there any way that using fluent API I can get the functionality what I was getting without it, Meaning (in case db logging fails log to windows event log).

Feel free to suggest in case of any discrepancy. :-)

1

1 Answers

2
votes

The exact syntax depends on your existing configuration. Assuming you have no trace listener or formatter already configured that you want to use:

configurationSourceBuilder
    .ConfigureLogging()
    .SpecialSources.LoggingErrorsAndWarningsCategory
    .SendTo.EventLog("Event Log Listener")
    .FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter"));

If you already have an Event Log trace listener configured that you want to use (named "Event Log Listener" in this example):

configurationSourceBuilder
    .ConfigureLogging()
    .SpecialSources.LoggingErrorsAndWarningsCategory
    .SendTo.SharedListenerNamed("Event Log Listener");

If you already have a log formatter configured that you want to use (named "Text Formatter" in this example):

configurationSourceBuilder
    .ConfigureLogging()
    .SpecialSources.LoggingErrorsAndWarningsCategory
    .SendTo.EventLog("Event Log Listener")
    .FormatWithSharedFormatter("Text Formatter");