2

Is there a way to always have the timestamppattern applied to my current log files?

Here is an example of my log file listener from app.config

<add name="Exception" 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="%APPDATA%\MyProgram\Logs\exception.log" formatter="PrismText"
rollFileExistsBehavior="Increment" rollInterval="Day" timeStampPattern="yyyy-MM-dd" rollSizeKB="3000"
maxArchivedFiles="10" />

Now once I hit the max size or date change, it renames the logs, but is there a way I can get the initial log file to show up with the TimeStamp Pattern?

I get this in my logs folder:

exception.log <-- Current log
exception.2011-12-22.1.log
exception.2011.12.22.2.log

I'd like this:

exception.2011-12-22.log (or exception.2011-12-22.1.log) <-- Current Log
exception.2011.12.22.2.log

Its not a huge deal as I can just look at the date modified/created, but it would be nice if its a quick fix.

John
  • 6,503
  • 3
  • 37
  • 58
  • 1
    I don't think this is 100% possible out of the box. I did see a Kludge with environment variables that involved a daily app restart. If you really, really wanted that feature you could create your own version of the RollingFlatFileTraceListener that worked that way. – Randy Levy Dec 30 '11 at 03:33
  • I didn't find a solution as well, I'm going to make mine. – lollancf37 Jan 26 '12 at 15:02

1 Answers1

0

What about giving the name of file as timestamp like this: exception.2011-12-22.log

You can do this by fluent api or if you dont want to use it from code you can change the config file everyday.If config file changes, Logging block automatically can change configuration. But of course this gonna make your code little bit complex.

Just an idea...

Yusuf Uzun
  • 1,491
  • 1
  • 13
  • 32