简体   繁体   English

从内部部署Service Fabric应用程序登录到Azure存储模拟器

[英]Logging to Azure Storage Emulator from on premise Service Fabric application

I have a named event source as part of my logging: 我有一个命名的事件源作为我的日志记录的一部分:

[EventSource(Name = "ExampleEventSource")]
internal sealed class ServiceEventSource : EventSource

I can see logs come in when I debug my application in Visual Studio. 当我在Visual Studio中调试应用程序时,我可以看到日志进来。 I now want to deploy my application on premise. 我现在想在内部部署我的应用程序。 This machine does not use Azure online services at all . 本机根本不使用Azure在线服务

How can I log events to a locally running Azure Storage Emulator on the premise machine? 如何将事件记录到驻留计算机上的本地运行的Azure存储模拟器? It seems really easy to enable logging from the Azure portal when dealing with an Azure virtual machine, but with a premise environment this feels extremely over-complicated and lacks some much needed documentation. 在处理Azure虚拟机时,从Azure门户启用日志记录似乎非常容易,但是在前提环境下,这种情况非常复杂,并且缺少一些非常需要的文档。 I tried searching online to find some concrete examples of how this can be done, and I read the Collect logs by using Azure Diagnostics article , but it didn't help and left many questions unanswered. 我尝试在线搜索以找到如何完成此操作的具体示例,并且使用Azure诊断文章阅读了收集日志 ,但它没有帮助,并且留下了许多未回答的问题。 For example, I even find myself stuck here: 例如,我甚至发现自己被困在这里:

Modify the template.json file by performing the following tasks. 通过执行以下任务来修改template.json文件。

What template.json file is this article referring to? 这篇文章指的是什么template.json文件? I am just publishing the solution directly to the remote premise machine from within Visual Studio and, since it is a local project, I presume that may be why there is no template.json which was required for the deployment as far as I can tell? 我只是从Visual Studio中直接将解决方案发布到远程前提机器上,因为它是一个本地项目,我认为这可能就是为什么我所知道的部署不需要template.json Not only that, but I am not sure if this article even truly covers on premise solutions to the same level of logging fruition I am looking for here. 不仅如此,我还不确定这篇文章是否真的涵盖了我在这里寻找相同水平的伐木结果的前提解决方案。

Any help is greatly appreciated, and I hope that whoever decides to help out can sympathize with those of us who want to maintain the same Azure framework for logging, but have it log locally in the emulator so we can use the Azure Explorer tool to view our logs, and I hope they can shed some insights into how this type of logging can be done locally for on-premise environments while maintaining some level of functionality with Visual Studio's deployment abilities. 非常感谢任何帮助,我希望无论谁决定提供帮助,都可以同情我们这些想要维护相同Azure框架进行日志记录的人,但让它在模拟器中本地登录,以便我们可以使用Azure Explorer工具查看我们的日志,我希望他们能够了解如何在本地环境中完成此类日志记录,同时使用Visual Studio的部署功能保持一定程度的功能。

Edit : I tried appending this to the end of my <ApplicationManifest> section within ApplicationManifest.xml file, but it did nothing: 编辑 :我尝试将其附加到ApplicationManifest.xml文件中的<ApplicationManifest>部分的末尾,但它没有做任何事情:

<Diagnostics>
  <ETWSource IsEnabled="true">
    <Destinations>
      <AzureBlob IsEnabled="true" ConnectionString="UseDevelopmentStorage=true" ConnectionStringIsEncrypted="false" ContainerName="traces" />
    </Destinations>
  </ETWSource>
</Diagnostics>

Edit : I know I can do this manually by using the Microsoft.Diagnostics.Tracing.TraceEvent NuGet package and subscribing to all of my events, but what is the proper way of logging my traces to file on premise, what is the on-premise Service Fabric-friendly way of achieving this? 编辑 :我知道我可以通过使用Microsoft.Diagnostics.Tracing.TraceEvent NuGet包手动执行此操作并订阅我的所有事件,但是将内容记录到内部文件的正确方法是什么,内部部署是什么服务Fabric友好的方式实现这一目标?

using (var session = new TraceEventSession("MyRealTimeSession"))
{
    session.Source.Dynamic.All += delegate (TraceEvent data)
    {
        Console.WriteLine(data);
        // Can add code to flush to Azure tables here...
    };
    var eventSourceGuid = TraceEventProviders.GetEventSourceGuidFromName("ExampleEventSource");
    session.EnableProvider(eventSourceGuid);
    session.Source.Process();
}

There's a quickstart example that does this. 这是一个快速启动的例子。 Have a look here . 看看这里 You could use this class. 你可以使用这个类。

The template.json they're talking about is the ARM template used to create resources in Azure with. template.json他们正在谈论的是用在Azure中创建资源与ARM的模板。

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

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