Rolling and Flat file : Redirecting based on the category (or) severity

Topics: Development Team Discussion, User Discussion
Developer
Jul 5, 2012 at 7:50 AM

Guys,

My first post and im very new to this Implementation,

The below is my config file :

  <loggingConfiguration name="loggingConfiguration" tracingEnabled="true" defaultCategory="Error" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        fileName="c:\Logs\TraceLog.txt" footer="----------------------------------------"
        formatter="Text Formatter" header="&quot;######################################&quot;"
        rollFileExistsBehavior="Overwrite" rollInterval="Day" timeStampPattern="mmddyy"
        traceOutputOptions="None" filter="Verbose" />
     
      <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        fileName="c:\Logs\ErrrorLog.txt" formatter="Text Formatter"
        traceOutputOptions="None" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        template="Timestamp: {timestamp(local)}{newline}Message: {message}{newline}"
        name="Text Formatter" />
    </formatters>
    <logFilters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        enabled="true" name="Rolling Flat File Trace Listener" />
    </logFilters>
    <categorySources>
      <add switchValue="All" name="Information">
        <listeners>
          <add name="Flat File Trace Listener" />
        </listeners>
      </add>
      <add switchValue="All" name="Verbose">
        <listeners>
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>        
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>


im able to write into "Flat file" and "Rolling file" issue im facing is im unable to write in to differnt logs based on the category (or) severity.

ex: right now im logging into only "Rolling file" i want only "Severity as Error" to be written into my "Rolling flat file" but every thg is getting logged..

if i use both "Flat and Rollling" how can i redirect them to different files ::


the below are the errors written..


"######################################"
Timestamp: 7/5/2012 12:02:52 PM
Message: There is no explicit mapping for the categories 'Trace'. The log entry was:
Timestamp: 7/5/2012 12:02:51 PM
Message: Trace Start
Category: Trace
Priority: 5
EventId: 100
Severity: Verbose
Title:RetrieveClaimsSummaryInfo
Machine: VAMSEZ218
App Domain: TestAppDomain: cf5ddc2b-9dd6-447b-824e-889dc0d53cb5
ProcessId: 6508
Process Name: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe
Thread Name: Agent: adapter run thread for test 'RetrieveClaimsSummaryInfoTest' with id '15890cf7-a1a2-4ed1-b66a-1e8703015c29'
Win32 ThreadId:6544
Extended Properties:

----------------------------------------
"######################################"
Timestamp: 7/5/2012 12:02:55 PM
Message: There is no explicit mapping for the categories 'Error'. The log entry was:
Timestamp: 7/5/2012 12:02:55 PM
Message: System.NullReferenceException: Object reference not set to an instance of an object.
   at Cig.Ums.Epas.Service.ServiceImplementation.PolicyService.RetrieveClaimsSummaryInfo(String policyId) in D:\Project\SourceCode-TFS\CIG.UMS.ePAS.Service.ServiceImplementation\PolicyService.cs:line 3516
Category: Error
Priority: -1
EventId: 100
Severity: Error
Title:RetrieveClaimsSummaryInfo
Machine: VAMSEZ218
App Domain: TestAppDomain: cf5ddc2b-9dd6-447b-824e-889dc0d53cb5
ProcessId: 6508
Process Name: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe
Thread Name: Agent: adapter run thread for test 'RetrieveClaimsSummaryInfoTest' with id '15890cf7-a1a2-4ed1-b66a-1e8703015c29'
Win32 ThreadId:6544
Extended Properties:

----------------------------------------

please help me in achieving the same..