Rolling Flat File Name Issue

Topics: Logging Application Block
Mar 6, 2012 at 6:01 AM

Hi, I'm using Enterprise Rolling flat file trace listener to log messages, but met a little name issue. My listener in config is as follows:

<add name="Rolling Flat File 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="Rolling.log" rollFileExistsBehavior="Increment" timeStampPattern="yyyy-MM-dd" maxArchivedFiles="10" rollInterval="Midnight" footer="" header="" />

With the config above, the archived file name becomes "Rolling.2012-03-06.1.log". Is it possible to remove ".1" in the file name? I just want "Rolling.2012-03-06.log". Thanks. 

Mar 6, 2012 at 6:21 AM
Edited Mar 6, 2012 at 3:30 PM

The reason why the .1 appears is that a file with the name Rolling.2012-03-06.log already exists and the configuration specifies to increment if the file exists.  The rollFileExistsBehavior can be changed to Overwrite that would ensure that your file will be named without the .1 but you could potentially have log files overwritten.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Mar 6, 2012 at 7:33 AM
randylevy wrote:

The reason why the .1 appears is that a file with the name Rolling.2012-03-06.log already exists and the configuration specifies to increment if the file exists.  The rollFileExistsBehavior can be changed to Overwrite that would ensure that your file will be named without the .1 but you could potentially have log files overwritten.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Hi Randy,

I am pretty sure that Rolling.2012-03-06.log doesn't exist. Is there any other reason?

Mar 6, 2012 at 3:07 PM

Actually, I was wrong there.  The sequence number is created whenever the RollFileExistsBehavior is set to Increment (even if the file does not exist).  If you want to avoid the sequence number then use Overwrite as the RollFileExistsBehavior.  This should be OK in your scenario since you are using a RollInterval of Midnight which means that you should only have one archived file per day.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com