Enterprise Library Logging

杀马特。学长 韩版系。学妹 提交于 2020-01-25 20:56:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!