Logging application block-how configure different listeners for different level of message.

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).
 
 


 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Sunday, January 18, 2009 2:24 PM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910