0

I'm trying to save my log in a chosen folder using Appinsight on java.

I've made an application which sends data in Azure when LTE connection is up, but how can I configure a specific folder in which I can save my data when I switch off my connection.

I also read in the documentation that the tempory folder is not configurable.

1 Answers1

0

You can check out the EventFlow project here https://github.com/Azure/diagnostics-eventflow

You can use that library to have multiple sources and multiple targets for you logs. In your case, you can have two outputs as shown below and when the LTE is available your logs will get sent to AppInsights and in its absence you will still log it in the local file.

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

Please note that at the current state it will log to StdOut only, but you can easily make it write to a file. You may refer this question on how to divert it to a file How to Save Console.WriteLine Output to Text File

Hope this helps

Guru Pasupathy
  • 440
  • 1
  • 4
  • 13