如何使用Appinsight Java配置发送日志的文件夹

问题描述 投票:0回答:1

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

我已经创建了一个应用程序,当LTE连接建立时,该应用程序在Azure中发送数据,但是当断开连接时,如何配置一个可以保存数据的特定文件夹。

我还阅读了文档,说临时文件夹是不可配置的。

java azure directory configure appinsights
1个回答
0
投票

您可以在https://github.com/Azure/diagnostics-eventflow处签出EventFlow项目

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

{
  "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,但是您可以轻松地将其写入文件。您可以参考有关如何将其转移到文件的问题How to Save Console.WriteLine Output to Text File

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.