TraceListener Filter have zero effect

Topics: Logging Application Block
Dec 18, 2009 at 3:51 AM

I've triple checked my work, read all the threads I can find here and done plenty of googling and I still don't understand why the LAB is completely ignoring a Filter I have set on a TraceListener.

When I log information severity items they are being emailed - it's as if the "Critical" filter does nothing at all.  More likely I'm missing something or confused, but I have no idea what I'm doing wrong.

 

Here are bits of my wrapper code around the Logger:

public static void LogInfo(string title, string message)
{
    Logger.Write(CreateLogEntry(title, message,
        TraceEventType.Information));
}

private static LogEntry CreateLogEntry(string title, string message,
    TraceEventType severity)
{
    LogEntry entry = new LogEntry();

    entry.Message = message;
    entry.Priority = 1;
    entry.Title = title;
    entry.Severity = severity;
    entry.Categories = new string[] { "General" };

    return entry;
}

Here is the relevant config file section:

<loggingConfiguration name="Logging Application Block" tracingEnabled="false"
    defaultCategory="" logWarningsWhenNoCategoriesMatch="false">
    <listeners>
      <add fileName="Logs/Errors.log" footer="" formatter="Text Formatter"
        header="&#xD;&#xA;----------------------------------------"
        rollFileExistsBehavior="Overwrite" rollInterval="None" rollSizeKB="1024"
        timeStampPattern="yyyy-MM-dd" 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="All - Rolling Flat File" />
      <add toAddress="xxx@xxxxx.com" fromAddress="xxxxx@xxxxxx.com"
        subjectLineStarter="xxxxx Exception -" subjectLineEnder=""
        smtpServer="xxxx.xxxx.com" smtpPort="25" formatter="" authenticate="true"
        username="xxxxx@xxxxx.com" password="xxxxxx" listenerDataType="Sprydon.TraceListeners.Configuration.AuthenticatingEmailTraceListenerData, Sprydon.AuthenticatingEmailTraceListener, Version=1.0.0.31884, Culture=neutral, PublicKeyToken=null"
        traceOutputOptions="None" filter="Critical" type="Sprydon.TraceListeners.AuthenticatingEmailTraceListener, Sprydon.AuthenticatingEmailTraceListener, Version=1.0.0.31884, Culture=neutral, PublicKeyToken=null"
        name="Errors - Email" />
    </listeners>
    <formatters>
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}"
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="All - Rolling Flat File" />
          <add name="Errors - Email" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
    </specialSources>
  </loggingConfiguration>

 

If anyone has any ideas for me share, I'm all ears!

 

Dec 18, 2009 at 7:23 AM

Hi,

I've noticed that you are using a custom trace listener, have you tried using a regular ent lib trace listener for these scenario?

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com