Errors & Warnings special sources doesn't work

Mar 31, 2010 at 12:45 PM

i'm trying to test what  happens when there is an error in the logging itself ( database link fails or category not exist, Etc....).

i read that when the logging fails the 'Errors & Warnings special sources' category is activated.

so i created a text Formatter and a Flat File TraceListener called "Logging Errors TraceListener" and referenced this listener in the 'Errors & Warnings special sources' category.

i also referenced the same listener in 'Unprocessed category".

then i wrote in C# :

Logger.Write("Asaf", "AsafCategory", 0, 0, TraceEventType.Information);

"AsafCategory" doesn't exist on purpose. i just wanted to test and see if a text file is created, BUT ITS NOT CREATED.

Why ?

this is the app.config:

 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="DefaultCategory" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add fileName="All Events.log" header="----------------------------------------"
        footer="----------------------------------------" formatter="All Events Formatter"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="All Events TraceListener" />
      <add fileName="LoggingErrors.log" header="----------------------------------------"
        footer="----------------------------------------" formatter="All Log Details Formatter"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Logging Errors TraceListener" />
      <add fileName="Summery.log" footer="-------------------------------------"
        formatter="Summery Formatter" header="-------------------------------------"
        rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="2000"
        timeStampPattern="dd_MM_yyyy" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Summery Trace Listener" />
      <add fileName="trace.log" header="" footer="" formatter="Tracer Formatter"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Tracer Trace Listener" />
    </listeners>
    <formatters>
      <add template="&#xD;&#xA;{message}&#xD;&#xA;&#xD;&#xA;Category: {category}&#xD;&#xA;"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="All Events Formatter" />
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="All Log Details Formatter" />
      <add template="&#xD;&#xA;{severity} Status:&#xD;&#xA;&#xD;&#xA;{message}&#xD;&#xA;&#xD;&#xA;"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Summery Formatter" />
      <add template="{message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Tracer Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="DefaultCategory">
        <listeners>
          <add name="Logging Errors TraceListener" />
        </listeners>
      </add>
      <add switchValue="All" name="SummeryCategory">
        <listeners>
          <add name="Summery Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="TracerCategory">
        <listeners>
          <add name="Tracer Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="Off" name="All Events">
        <listeners>
          <add name="All Events TraceListener" />
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="Logging Errors TraceListener" />
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Logging Errors TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
</configuration>

 

Please Help.

Apr 5, 2010 at 2:36 AM

Hi rodnikoNo1,

Try removing your Trace Listener Reference in your Special Sources > All Events. Which should now look like this

<specialSources>
      <allEvents switchValue="Off" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="Logging Errors TraceListener" />
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Logging Errors TraceListener" />
        </listeners>
      </errors>
    </specialSources>

HTH,

~ginkapitan