[英]How to add logging to Windows Event Log using system.diagnostics
我创建了自定义WCF LOB适配器。 我在其中使用Trace类。 我希望BizTalk服务器将日志从该适配器写入Windows事件日志。
当我将以下部分添加到BizTalk主机配置文件时,BizTalk无法启动。 怎么了
<system.diagnostics>
<trace autoflush="true">
<sources>
<source name="AzureServiceBusClient" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureServiceBusTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="AzureServiceBusTraceListener" type="System.Diagnostics.EventLogTraceListener" initializeData="BizTalk Server" />
</sharedListeners>
</trace>
</system.diagnostics>
这是在代码中创建跟踪类的方式:
//
// Initializes a new instane of Microsoft.ServiceModel.Channels.Common.AdapterTrace using the specified name for the source
//
static AdapterTrace trace = new AdapterTrace("AzureServiceBusClient");
源应该是跟踪的单独项目,而不是在拥有它们时嵌套。 我认为您一定忘记了自己终止跟踪标记,然后在其中添加结束标记,使其无效。
将其更正为以下内容应该可以解决您的BizTalk无法启动的问题。
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="AzureServiceBusClient" switchValue="Verbose, ActivityTracing">
<listeners>
<add name="AzureServiceBusTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="AzureServiceBusTraceListener" type="System.Diagnostics.EventLogTraceListener" initializeData="BizTalk Server" />
</sharedListeners>
</system.diagnostics>
下面的示例来自诊断跟踪和消息记录
<system.diagnostics>
<sources>
<source name ="System.ServiceModel" switchValue="Verbose">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name ="System.ServiceModel.MessageLogging"
switchValue="Verbose, ActivityTracing">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name ="System.Runtime.Serialization" switchValue="Verbose">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener"
traceOutputOptions="LogicalOperationStack"
initializeData="C:\log\WCFTrace.svclog" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false"/>
</diagnostics>
</system.serviceModel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.