views:

67

answers:

2

I have a log Mysite.log

Is possible to automatically separate in Mysite.error.log, Mysite.debug.log, Mysite.warning.log? Depending of TraceEventType?

A: 

You can implement filters for this purpose or alternatively write them using different appenders.

jm04469
+1  A: 

We do it like this:

        Logger.Write("Message or exception", "Catergory");

Where category in your case would be Errors, debug or warning.

Then in your config file for Errors:

<listeners>
  <add fileName="Errors.log" footer="----------------------------------------"
    header="----------------------------------------" rollFileExistsBehavior="Overwrite"
    rollInterval="None" rollSizeKB="0" timeStampPattern="yyyy-MM-dd"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    name="Errors" />
</listeners>


<categorySources>
  <add switchValue="All" name="Errors">
    <listeners>
      <add name="Errors" />
    </listeners>
  </add>
</categorySources>

You need to do this for each category

Shiraz Bhaiji