问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/5804766/enterprise-library-logging