简体   繁体   English

如何从Service Fabric外部将日志发送到ServiceEventSource?

[英]How to send logs to ServiceEventSource from outside of Service Fabric?

I'm not even sure if this is possible but I have my Service Fabric microservices sending log information to ServiceEventSource by using: 我什至不确定这是否可行,但是我的Service Fabric微服务使用以下方式将日志信息发送到ServiceEventSource:

ServiceEventSource.Current.ServiceMessage(this.Context, "this is my log message");

My external (non-Service Fabric) application consumes the Stateless WebAPI (Service Fabric) but it currently logs to a text file. 我的外部(非Service Fabric)应用程序使用了Stateless WebAPI(Service Fabric),但当前将其记录到文本文件中。 Is there a way to have my external applications somehow also log to ServiceEventSource so I don't have to look in both places? 有没有办法让我的外部应用程序也以某种方式登录到ServiceEventSource,这样我就不必在两个地方都查看?

Simply share the ServiceEventSource class with your external application. 只需与外部应用程序共享ServiceEventSource类。 You could do this by simply sharing the code or by packaging it in a NuGet package or by referencing the built .dll in your external application. 您可以通过简单地共享代码或将其包装在NuGet包中,或通过在外部应用程序中引用内置的.dll来执行此操作。

A word of caution: EventSource and ETW logging in general is very picky. 请注意:EventSource和ETW日志记录通常非常挑剔。 Your definition of the EventSource really should be identical in both places, our it will very likely not work at all, or fail in strange and hard to understand ways. 您对EventSource的定义实际上在两个地方都应该相同,我们很可能根本不起作用,或者以奇怪且难以理解的方式失败。

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

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