使用 Enterprise Library 5.0 日志记录时,我遇到了不稳定的日志记录。
问题在于托管在 IIS (7.5) 中的 WCF 4.0 应用程序,该应用程序在负载平衡配置的 Windows 2008 R2 服务器上运行。我正在使用 Unity (2.0) 进行依赖注入。我已将库配置为记录到滚动文本文件。该应用程序使用 AppFabricCache。
似乎在重新启动托管服务的 Web 应用程序后的前几次调用中记录成功。此后,看不到进一步的日志记录。我要么在配置中出错,要么在将输出写入/刷新到文本文件时可能存在一些争用。我了解 Logging 类以线程安全的方式运行。
下面是配置文件的相关部分。任何想法表示赞赏。谢谢。
<loggingConfiguration name="loggingConfiguration" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Rolling File Trace Listener"
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="d:\SOMEPATH\Logs\trace.log"
formatter="Text Formatter"
header="" footer=""
timeStampPattern="yyyy-MM-dd hh:mm:ss.fff"
traceOutputOptions="None"
maxArchivedFiles="2000"
rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="1024" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="{timestamp(yyyyMMdd HH:mm:ss.fff)} - {message}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Rolling File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Rolling File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>