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,

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">
      <add fileName="Logs/Errors.log" footer="" formatter="Text Formatter"
        rollFileExistsBehavior="Overwrite" rollInterval="None" rollSizeKB="1024"
        timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="All - Rolling Flat File" />
      <add toAddress="" fromAddress=""
        subjectLineStarter="xxxxx Exception -" subjectLineEnder=""
        smtpServer="" smtpPort="25" formatter="" authenticate="true"
        username="" password="xxxxxx" listenerDataType="Sprydon.TraceListeners.Configuration.AuthenticatingEmailTraceListenerData, Sprydon.AuthenticatingEmailTraceListener, Version=, Culture=neutral, PublicKeyToken=null"
        traceOutputOptions="None" filter="Critical" type="Sprydon.TraceListeners.AuthenticatingEmailTraceListener, Sprydon.AuthenticatingEmailTraceListener, Version=, Culture=neutral, PublicKeyToken=null"
        name="Errors - Email" />
      <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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Text Formatter" />
      <add switchValue="All" name="General">
          <add name="All - Rolling Flat File" />
          <add name="Errors - Email" />
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings" />


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


Dec 18, 2009 at 7:23 AM


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.