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> 
Do NOT confuse listeners/add filter property (local for a listener) with  logFilters section(global for the LAB).
 

posted @ Sunday, January 18, 2009 2:24 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345