【发布时间】:2020-11-19 09:58:14
【问题描述】:
我在 C# 应用程序的 app.config 中使用 Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener,如下所示:
<listeners>
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="RollingFlatFile.log"
footer="----------------------------------"
formatter="Text Formatter"
header="" rollInterval="Day"
timeStampPattern="yyyy-MM-dd hh:mm:ss"
traceOutputOptions="DateTime, Timestamp"
filter="All" />
<add name="Event Log Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Application" formatter="Text Formatter" log="Application" machineName="." traceOutputOptions="None" />
</listeners>
我希望该文件名也应包含日期,例如 RollingFlatFile_19Nov2020.log。任何人都可以通过更改此配置文件来帮助我如何实现这一目标。
【问题讨论】:
标签: c# logging tracelistener