Question

My desire output is, if "rolling.log" file was created and modified by 26-06-2012, next day(27-06-2012) that file should be renamed with "rolling-26-06-2012..log". Now output is "rolling-27-06-2012.log" file.

Below is my current logging setting in web.config file.

<*loggingConfiguration name="" tracingEnabled="true" defaultCategory="myTestLog">

<*listeners>

  <*add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="C:\Project\Others\Testing\testMSLogging\rolling.log"
    formatter="Text Formatter" rollFileExistsBehavior="Increment"
    rollInterval="Minute" rollSizeKB="50" timeStampPattern="yyMMdd"
    filter="Information" />

  <*add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="C:\Project\Others\Testing\testMSLogging\testMSLogging\trace.log"
    formatter="Text Formatter" filter="Error" />
</listeners>

<*formatters>

  <*add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
    name="Text Formatter" />
</formatters>

<*categorySources>

  <*add switchValue="All" name="myTestLog">
    <*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="Flat File Trace Listener" />
    </listeners>
  </errors>
</specialSources>

Please anyone help me. Thanks a lot.

Was it helpful?

Solution

Unfortunately this is the way it works in Enterprise Library. The philosophy behind its default flat file roller is that it records all the output in FILE.LOG and when the roll event happens, it renames it to FILE-ROLL-NAME.LOG and creates a new FILE.LOG If you need a different behavior, you may need to create your own logging trace listener or use other tools out there like log4net.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top