Change Trace FileName At Runtime

Topics: Logging Application Block
Oct 9, 2007 at 10:33 AM
Hi,
I'm using Logging Application block.
I need to create a new flat log file everyday to archive old logs.
How can I change listener file name at runtime?
Oct 9, 2007 at 3:47 PM
If you use the Rolling Trace Listener (RollingFlatFileTraceListenerData). It will change the filename based on Date or Size

Ex:
<listeners>
<add name="Text Listener" fileName="Trace.log" rollSizeKB="0" timeStampPattern="yyyy-MM-dd" rollFileExistsBehavior="Increment" rollInterval="Day" formatter="Short" header="" footer=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="ThreadId" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</listeners>