logging - Microsoft Enterprise Library 4.1 日志记录在 Windows XP SP3 上失败

标签 logging windows-xp enterprise-library

我有一个使用 Ent Lib 4.1 日志记录应用程序 block 的应用程序。此应用程序在 XP SP2+、Windows Vista 和 Windows 7 上运行。

大多数时候,我的日志记录工作正常。 (它通常以事件日志跟踪监听器为目标。)有时,我不确定是什么触发了它,Windows XP 计算机将简单地停止日志记录。我尝试添加平面文件跟踪监听器以查看问题是否与事件日志有关,但平面文件也不起作用。重新启动也无法解决问题。

在所有出现故障的机器上,它之前一直在工作。它似乎也与 Windows XP SP2/SP3 隔离。 Vista 或 7 上不会发生这种情况。

想法?

更新:我尝试删除除平面文件之外的所有跟踪监听器,并且这有效。所以问题出在事件日志跟踪监听器上,显然发生的任何事情都会导致 Ent Lib 完全无法记录任何内容 - 包括有关日志记录过程的错误。

最佳答案

@RMD,你是对的。当引发异常时(例如事件日志已满),该异常会导致该类别的所有其他跟踪监听器不被处理。

no log entry will be recorded for any trace listener.

另一方面,这并不完全正确。是的,所有常规跟踪监听器都不会被处理,但仍然存在错误特殊源。我建议将其设置为自己的文件(根据我的经验,EventLog 会给出更多权限问题等)以捕获任何日志记录错误:

<specialSources>
  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <add name="Error Flat File Destination" />
    </listeners>
  </errors>
</specialSources>

如果使用适当的权限进行设置并且磁盘未满(等),那么您会在该日志文件中看到错误以及原始信息:

Message: Tracing to LogSource 'Your Event Source' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks.

Summary for Enterprise Library Distributor Service:
======================================
[Original Log Entry]

Exception Information Details:
====================================== 
Exception Type: System.ComponentModel.Win32Exception
NativeErrorCode: 1502 
ErrorCode: -2147467259 
Message: The event log file is full 
Data: System.Collections.ListDictionaryInternal
TargetSite: Void InternalWriteEvent(UInt32, UInt16, System.Diagnostics.EventLogEntryType, System.String[], Byte[], System.String) 
HelpLink: NULL 
Source: System

因此,您将获得原始日志信息,您可以提取该信息并将其手动插入到您保存的任何日志历史记录中(例如报告、分析)。另外,作为奖励,您还可以获得有关为何无法写入日志条目的信息,以便可以(希望如此!)对其进行修复。

关于logging - Microsoft Enterprise Library 4.1 日志记录在 Windows XP SP3 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4784241/

相关文章:

java - Log4j2 - Asynclogger Rolling File Appender 不是每天每小时滚动一次

python - 如何将日期时间添加到日志文件名?

java - 如何登录不同的文件? log4j2

windows-xp - 使用 Microsoft XP SP2 进行蓝牙应用程序开发

unity-container - 统一/EntLib : Injecting a dependency into a CustomTraceListener

python - 将日志级别设置为 logging.DEBUG 或 logging.INFO 无效

windows - ImageList_Add 在由 pcAnywhere 控制的 PC 上返回 -1

windows - 用于更改计算机上所有网络共享的批处理文件

unity-container - 如何注册实现相同接口(interface)的多个类型

.net - 企业库日志记录未从 ASP.NET 记录到事件日志