0

Log file names now support the use of environment variables. You can include environment variables such as %WINDIR%, %TEMP%, and %USERPROFILE% in the Filename property of the Flat File Trace Listener, Rolling Flat File Trace Listener, and XML Trace Listener.

<add name="Trace" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="Logs\trace_%DATE%.log" header="" footer="" formatter="Trace"
traceOutputOptions="None" filter="All" />

Result filename - trace_.log, what am I doing wrong?

Gary Green
  • 22,045
  • 6
  • 49
  • 75
Alex
  • 53
  • 1
  • 4
  • Personally, I don't see a lot of value in having the date/time at which the log file was started as part of the file name. I'd rather have the current file named something like "trace_current.log" and use the RollingFlatFileTraceListener to archive old files. It automatically puts a timestamp in the filename of rolled files. – Dr. Wily's Apprentice Apr 27 '11 at 13:57
  • Thanks! RollingFlatFileTraceListener is the answer i'v been looking for – Alex Apr 28 '11 at 14:22

1 Answers1

0

DATE is a dynamic environment variable (i.e., one who's value can change during a session), and I don't think EL supports those.

See Add date to log file name in Logging Application Block for a possible solution, but it's not an ideal one.

Community
  • 1
  • 1
RB.
  • 36,301
  • 12
  • 91
  • 131