【问题标题】:How to configure a folder where send log with Appinsight java如何配置使用 Appinsight java 发送日志的文件夹
【发布时间】:2023-04-06 00:15:01
【问题描述】:

我正在尝试使用 Java 上的 Appinsight 将我的日志保存在选定的文件夹中。

我已经制作了一个应用程序,当 LTE 连接启动时在 Azure 中发送数据,但是如何配置一个特定文件夹,以便在我关闭连接时保存我的数据。

我还在文档中读到临时文件夹不可配置。

【问题讨论】:

    标签: java azure directory configure appinsights


    【解决方案1】:

    您可以在这里查看 EventFlow 项目https://github.com/Azure/diagnostics-eventflow

    您可以使用该库为您的日志提供多个来源和多个目标。在您的情况下,您可以有两个输出,如下所示,当 LTE 可用时,您的日志将被发送到 AppInsights,如果没有,您仍会将其记录在本地文件中。

    {
      "inputs": [
        {
          "type": "Trace",
          "traceLevel": "Warning"
        }
      ],
      "outputs": [
        // Please update the instrumentationKey.
        {
          "type": "ApplicationInsights",
          "instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
        },
        {
          "type": "StdOutput"
        }
      ],
      "schemaVersion": "2016-08-11"
    }
    

    请注意,在当前状态下,它只会记录到 StdOut,但您可以轻松地将其写入文件。您可以参考this question关于如何将其转移到文件How to Save Console.WriteLine Output to Text File

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 1970-01-01
      • 2019-11-11
      • 2018-08-08
      相关资源
      最近更新 更多