简体   繁体   English

记录System.ServiceModel时的远程服务跟踪侦听器

[英]Remote Service Trace Listener while logging System.ServiceModel

In our project we need to transmit the client side logging to a server. 在我们的项目中,我们需要将客户端日志记录传输到服务器。 Server-side, we created a WCF service that can receive the logging lines and dump them into a flat file/xml file/database (not important). 在服务器端,我们创建了一个WCF服务,该服务可以接收日志记录行并将其转储到平面文件/ xml文件/数据库中(不重要)。 Client-side, we created a RemoteTraceListener (with attributes to configure the endpoint, etc) calling that logging service. 在客户端,我们创建了一个RemoteTraceListener(具有配置端点的属性等)来调用该日志记录服务。 We use the standard .Net tracing with trace sources (TraceData, TraceEvent) to create the logging. 我们使用带有跟踪源(TraceData,TraceEvent)的标准.Net跟踪来创建日志记录。

Now, this all goes well, unless we hook up the RemoteTraceListener to the "System.ServiceModel" trace source at the client to investigate other service calls. 现在,一切顺利,除非我们在客户端将RemoteTraceListener连接到“ System.ServiceModel”跟踪源以调查其他服务调用。 This obviously goes very wrong. 这显然是非常错误的。

  • System.ServiceModel trace source message of MalfunctioningServiceX is logged to RemoteTraceListener. MalfunctioningServiceX的System.ServiceModel跟踪源消息记录到RemoteTraceListener。
  • RemoteTraceListener makes Wcf connection to send out the logging line to logging service RemoteTraceListener建立Wcf连接以将日志记录行发送到日志记录服务
  • System.ServiceModel trace source message of RemoteTraceListener is logged to RemoteTraceListener. RemoteTraceListener的System.ServiceModel跟踪源消息记录到RemoteTraceListener。
  • ... ...

And after that, the messages just keep flooding. 之后,这些消息只会不断泛滥。 Ideas on solving this recursion, please? 请问有解决此递归的想法吗?

After thorough searching, the possible solutions split itself in three categories: 彻底搜索后,可能的解决方案将自己分为三类:

  • Don't use WCF to transmit the logging (use a logging framework using another method of communication) 不要使用WCF传输日志记录(使用使用另一种通信方法的日志记录框架)
  • First log locally and stop logging when transmitting the log file or use another method to transmit the log file. 首先在本地记录日志,然后在传输日志文件时停止记录,或使用其他方法传输日志文件。
  • Separate the transmission from the application, using another executable or another AppDomain 使用另一个可执行文件或另一个AppDomain将传输与应用程序分开

We chose to follow the last method. 我们选择遵循最后一种方法。 We have rewritten our TraceListener to write internally to a queue. 我们已经重写了TraceListener以便在内部写入队列。 Internally a second AppDomain is started, dequeuing and transmitting the logging to the server. 内部启动第二个AppDomain,将日志出队并传输到服务器。 This can be written in half a day. 这可以在半天之内完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM