gpt4 book ai didi

logging - 企业库5 : Exceptions not being logged to Event log on Windows Azure

转载 作者:行者123 更新时间:2023-12-03 04:52:40 26 4
gpt4 key购买 nike

我有一个部署为 Windows Azure Web 角色的 WCF 服务。

我正在使用 Enterprise Library 进行异常处理,并且在我的本地 Development Fabric 中,似乎可以使用事件日志处理程序正确处理和记录异常(记录到应用程序事件日志)。

当它在 Azure 上运行时,虽然似乎应用了异常策略(因为我正在观察某些预期异常的正确处理),但事件日志中没有记录任何内容。

这是异常处理策略:

<add name="Entity">
<exceptionTypes>
<add name="All Exceptions"
type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="NotifyRethrow">
<exceptionHandlers>
<add name="Logging Exception Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
logCategory="General"
eventId="100"
severity="Error"
title="Enterprise Library Exception Handling"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
priority="0" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>

这是日志记录配置:

 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Event Log Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Enterprise Library Logging" formatter="Text Formatter"
log="Application"
machineName="."
traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
</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: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Event Log Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors &amp; Warnings">
<listeners>
<add name="Event Log Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

知道出了什么问题吗?

最佳答案

进行日志记录的最佳方法是使用诊断跟踪监听器。 Windows Azure 中事件日志的名称不同。要使用此企业库,您需要从事件日志监听器更改为 Windows Azure 诊断跟踪监听器。我们在“Moving Applications to the Cloud”一书中提供了更多相关信息。代码位于 VS 2008 中,但您可以在 VS 2010 中打开以查看示例。在代码中,了解我们如何使用 Windows Azure 诊断跟踪监听器设置企业库日志记录。您需要确保将日志移过来才能查看信息。书中对此进行了详细介绍。

如果您想快速浏览一下,可以下载音乐应用程序 here来 self 们的 codeplex 网站,该网站展示了如何将 Enterprise Library 与 Windows Azure 结合使用。这是我们正在努力升级的旧版本。

有关追踪的更多信息 here .

关于logging - 企业库5 : Exceptions not being logged to Event log on Windows Azure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5979370/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com