I'm trying to rotate log files, one per day of week and this configuration file is not working. If I change it to rotate instead of midnight to minute it only records one single file with one minute duration. No new files are being generated. Are there any known bugs of the latest version of entreprise library that focus on rolling flat files not working? Is there any problem with my current configuration? Thank you!
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General"
revertImpersonation="false">
<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:\EMS\logs\MobileMessagingServices.log" footer="" formatter="Text Formatter"
header="" rollFileExistsBehavior="Increment" rollInterval="Midnight"
rollSizeKB="100000" timeStampPattern="yyyy-MM-dd hh:mm:ss" maxArchivedFiles="7"
traceOutputOptions="Timestamp, Callstack" filter="All" />
</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} :: {category} :: {message}" name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
I managed to reproduce your example.
It appears that your problem is in the time-stamp pattern. You use colon (:) as a delimiter for minutes and seconds; when the timestamp gets concatenated to the file name, that name doesn't get accepted because the colon is a reserved character. You don't see the error, since your 'errors' special source is also configured to use the Rolling Flat File Trace Listener.
Replace colon with space, dash, underscore or any other character which is valid for a file name and everything will work. Also, consider configuring a separate listener for the error category.
Also, since you chose rollFileExistsBehavior="Increment" and not "Overwrite", it will add a .1 suffix to each file. The suffix will not increment, since you are going to get a new file every second. You may want to remove ss from the time pattern or change the rollFileExistsBehavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With