Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
and AvanadeSupport gave me the answer to use  "Filter" property of the tracelistener.
MSDN Source Schema for the Logging Application Block   documents listeners Child Element (loggingConfiguration)/add Child Element
Now I am able to make configuration like the following

<loggingConfiguration name="Logging Application Block" tracingEnabled="true">
 
<categorySources>
      <add switchValue="All" name="MyApp">
           <listeners>
                 <add name="EventLog Listener" />
                <add name="EMailErrors TraceListener" />
           </listeners>
      </add>
</categorySources
<listeners>
      <
add name="EMailErrors TraceListener"     filter="Error"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null
            
toAddress="to@example.com"
              
fromAddress="from@example.com"
              
subjectLineStarter="test end"
              
subjectLineEnder="test start"
              
smtpServer
="127.0.0.1"
              
smtpPort="25"
              
formatter
=" Simple Text Formatter "
              
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration. EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"
              
traceOutputOptions="None" 
               /
>
      </add>
</
listeners>
</loggingConfiguration> 
I found for Mail listerners that despite of SourceLevels Enumeration  documentation, specified values do not include more serious events, e.g.  filter="Warnings" will apply for Warnings ONLY, not including Critical, Error, and Warning events.
You have to explicitely declare and assign separate listerners for Error Warning or Information .
 
Do NOT confuse listeners/add filter property (local for a listener) with  logFilters section(global for the LAB).
 
 


 

Posted on Sunday, January 18, 2009 2:24 PM Testing/Debugging/Logging | Back to top


Comments on this post: Logging application block-how configure different listeners for different level of message.

# re: Logging application block-how configure different listeners for different level of message.
Requesting Gravatar...
You say, "you have to explicitely declare and assign separate listerners for Error, Warning or Information."

If you want to have the same behaviour, you can set the filter like this:
filter="Critical,Error,Warning"
Left by Matthias on May 21, 2014 12:03 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net