共用方式為


透過 API 上傳當機

重要

Visual Studio App Center 已排定於 2025 年 3 月 31 日淘汰。 雖然您可以繼續使用 Visual Studio App Center,直到完全淘汰為止,但有數個建議的替代方案可以考慮移轉至。

深入瞭解支持時程表和替代方案。

如果您不想使用我們的 SDK 或針對自訂平台進行開發,您可以上傳當機報告。 將 損毀錯誤或附件記錄上傳至 App Center,並在 App Center 診斷 UI 中檢視詳細數據。 下列各節將說明如何上傳 當機錯誤附件

注意

App Center 只接受每個唯一應用程式每分鐘最多 60 次當機和已處理的錯誤。 我們不會擷取任何超過此限制的當機或錯誤。

若要上傳報告,請使用下列標頭呼叫 的 https://in.appcenter.ms/logs?Api-Version=1.0.0 App Center 擷取端點:

  • Content-Type:描述本文的格式。 App Center 目前僅支援 JSON 格式。
  • App-Secret:每個應用程式的唯一標識符字串。 您可以在應用程式的設定中找到應用程式密碼。
  • Install-ID:可以是用來追蹤計數之任何 GUID 的字串。

記錄屬性:

  • type:具有記錄類型的必要字串 - “appleError” 代表 Apple 當機、“managedError” 代表其他當機、“handledError” 代表錯誤,以及錯誤附件的 “errorAttachment”。
  • timestamp:具有記錄時間戳日期時間的選擇性字串,例如 “2017-03-13T18:05:42Z” - 如果設定,在擷取的未來時間最多需要 72 小時
  • appLaunchTimestamp:指定應用程式啟動時時間戳日期時間的必要字串,例如 “2017-03-13T18:05:42Z”。
  • device:具有裝置特性的必要物件
    • appVersion:具有應用程式版本名稱的必要字串,例如 “1.1.0”
    • appBuild:具有應用程序組建編號的必要字串,例如 “42”
    • sdkName:具有 SDK 名稱的必要字串。 包含 SDK 和平台的名稱,例如適用於 Android 的 「appcenter.android」,以及自定義平臺的 「appcenter.custom」。
    • sdkVersion:具有語意版本設定格式之 SDK 版本的必要字串,例如 “1.2.0” 或 “0.12.3-alpha.1”
    • osName:具有OS名稱的必要字串,例如 “android”
    • osVersion:具有OS版本的必要字串,例如 “9.3.0”
    • model:具有裝置型號的選擇性字串,例如 “iPad2”
    • locale:具有語言代碼的必要字串,例如 “en-US”
    • timeZoneOffset:從裝置時區的國際標準時間 (UTC) 之間的選擇性位移, (介於 -840 到 840) 之間。 包括日光節約時間,例如120。
  • userId:選擇性字串,用於將記錄與用戶產生關聯
  • exception:具有例外狀況詳細數據的必要物件
    • type:具有例外狀況類型的必要字串
    • frame:具有堆疊框架的選擇性陣列
    • message:具有例外狀況原因的選擇性字串
    • stackTrace:具有原始堆疊追蹤的選擇性字串
    • innerException:具有內部例外狀況的選擇性陣列

您可以在下方找到如何上傳當機報告、錯誤報告和附件的範例。 如需更多規格,您可以 在這裡找到完整的檔案。

注意

由於保留原則,報表 timestamp 未來必須不超過 25 天或 3 天。

上傳當機報告

上傳損毀報告需要下列屬性:

  • processId:具有進程標識碼的必要整數
  • id:具有例外狀況標識碼的必要字串,必須是此報表的唯一標識符
  • fatal:必要的布爾值,指出例外狀況是否導致當機
  • processName:具有進程名稱的必要字串
  • appNamespace:Android 應用程式的必要專案,否則為具有套件組合標識碼、套件標識碼或命名空間的選擇性字串,視使用的平臺而定。

若要上傳 Apple 格式以外的損毀報告,請確定記錄類型已設定為 「managedError」。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "timestamp": "2019-10-08T04:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "processId": "123",
      "id": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "fatal": true,
      "processName": "com.microsoft.appcenter.demo.project",
      "device": {
        "appVersion": "12.0",
        "appBuild": "1",
        "sdkName": "custom.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US",
        "appNamespace": "com.contoso.myapp"
      },
      "userId": "TestID",
      "exception": {
        "type": "java.lang.RuntimeException",
        "frames": [
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2575,
            "methodName": "performResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2603,
            "methodName": "handleResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2089,
            "methodName": "handleLaunchActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 130,
            "methodName": "access$600"
          },
          {
            "className": "android.app.ActivityThread$H",
            "fileName": "ActivityThread.java",
            "lineNumber": 1195,
            "methodName": "handleMessage"
          },
          {
            "className": "android.os.Handler",
            "fileName": "Handler.java",
            "lineNumber": 99,
            "methodName": "dispatchMessage"
          },
          {
            "className": "android.os.Looper",
            "fileName": "Looper.java",
            "lineNumber": 137,
            "methodName": "loop"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 4745,
            "methodName": "main"
          }
        ],
        "innerExceptions": [
          {
            "type": "java.lang.RuntimeException",
            "frames": [
              {
                "className": "android.app.Activity",
                "fileName": "Activity.java",
                "lineNumber": 5084,
                "methodName": "performResume"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2565,
                "methodName": "performResumeActivity"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2603,
                "methodName": "handleResumeActivity"
              }
            ]
          }
        ]
      }
    }
  ]
}'

上傳 Apple 損毀記錄

若要上傳 Apple 損毀記錄檔,請確定記錄類型已設定為 “appleError”。 也需要下列屬性:

  • primaryArchitectureId:具有 CPU 主要架構的必要整數
  • applicationPath:具有應用程式路徑的必要字串
  • osExceptionType:具有OS例外狀況類型的必要字串
  • osExceptionCode:具有OS例外狀況代碼的必要字串
  • osExceptionAddress:具有OS例外狀況位址的必要字串
  • binaries:與錯誤相關聯的二進位檔所需的陣列

例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
        "type": "appleError",
        "timestamp": "2019-10-08T02:44:55.000Z",
        "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
        "id": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
        "applicationPath": "iOS/salesforce",
        "osExceptionType": "CustomerIssue (TestIssue)",
        "osExceptionCode": "0",
        "osExceptionAddress": "0x00",
        "processName": "salesforce",
        "fatal": true,
        "isTestMessage": false,
        "device": {
          "appVersion": "10.0",
          "appBuild": "1",
          "sdkName": "custom.ios",
          "sdkVersion": "1.0.0",
          "osName": "iOS",
          "osVersion": "9.3",
          "model": "iPhone9,1",
          "locale": "en-US"
        },
        "userId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
        "fatal": true,
        "threads": [
         {
          "id": 0,
          "frames": [
            {
              "address": "0x000000018ada4d70",
              "code": "0x18ad87000 + 122224"
            },
            {
              "address": "0x0000000104463884",
              "code": "0x10445c000 + 30852"
            },
            {
              "address": "0x000000010438f640",
              "code": "0x104388000 + 30272"
            },
            {
              "address": "0x00000001b859fb64",
              "code": "0x1b8229000 + 3631972"
            }
          ]
        },
        {
          "id": 1,
          "frames": [
            {
              "address": "0x000000018bb4fce0",
              "code": "0x18baa2000 + 711904"
            },
            {
              "address": "0x000000018bbf7078",
              "code": "0x18baa2000 + 1396856"
            },
            {
              "address": "0x000000018baa8258",
              "code": "0x18baa2000 + 25176"
            },
            {
              "address": "0x000000018bb1c49c",
              "code": "0x18baa2000 + 500892"
            }
          ]
        },
        {
          "id": 3,
          "frames": [
            {
              "address": "0x000000018b755b9c",
              "code": "0x18b732000 + 146332"
            },
            {
              "address": "0x000000018b7dcd00",
              "code": "0x18b7ce000 + 60672"
            }
          ]
        }
      ],
      "binaries": [
        {
          "id": "d449e33d-7e74-379d-8b79-15ee104ed1df",
          "startAddress": "0x0000000104388000",
          "endAddress": "0x0000000104413fff",
          "name": "CrashProbeiOS",
          "path": "/var/containers/Bundle/Application/023013EA-0D58-4F6D-8B98-49E1372F4044/CrashProbeiOS.app/CrashProbeiOS",
          "primaryArchitectureId": 16777228,
          "architectureVariantId": 0
        },
        {
          "id": "5da23653-d126-39f0-bdcf-994b3019f92c",
          "startAddress": "0x000000010445c000",
          "endAddress": "0x0000000104467fff",
          "name": "CrashLibiOS",
          "path": "/private/var/containers/Bundle/Application/023013EA-0D58-4F6D-8B98-49E1372F4044/CrashProbeiOS.app/Frameworks/CrashLibiOS.framework/CrashLibiOS",
          "primaryArchitectureId": 16777228,
          "architectureVariantId": 0
        }
      ]
    }
  ]
}'

上傳自定義損毀記錄

若要上傳自定義平臺的當機,請確定記錄類型設定為 「managedError」,且 sdkName 設定為 「appcenter.custom」。。 例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "id": "a7bea41b-1e4d-4e42-ae76-1025f4fdfc4f",
      "userId": "TestID",
      "timestamp": "2019-11-26T02:00:04Z",
      "appLaunchTimestamp": "2019-11-26T02:00:04Z",
      "architecture": "armeabi-v7a",
      "fatal": true,
      "processId": 4871,
      "processName": "com.microsoft.appcenter.sasquatch.project",
      "sid": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "errorThreadId": 1,
      "errorThreadName": "main",
      "device": {
        "appBuild": "1337",
        "appVersion": "7.1.0",
        "appNamespace": "com.microsoft.appcenter.sasquatch.project",
        "carrierCountry": "us",
        "locale": "en_US",
        "model": "Galaxy Nexus",
        "oemName": "samsung",
        "osApiLevel": 16,
        "osBuild": "JRO03O",
        "osName": "Android",
        "osVersion": "5.0.0",
        "screenSize": "720x1184",
        "sdkName": "appcenter.custom",
        "sdkVersion": "1.9.1",
        "timeZoneOffset": -480
      },
       "exception": {
        "frames": [
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2575,
            "methodName": "performResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2603,
            "methodName": "handleResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2089,
            "methodName": "handleLaunchActivity"
          }
        ],
        "innerExceptions": [
          {
            "frames": [
              {
                "className": "android.app.CustomActivity",
                "fileName": "CustomActivity.java",
                "lineNumber": 8673,
                "methodName": "performCustomResume"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2565,
                "methodName": "performResumeActivity"
              }
            ],
            "message": "Activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2} did not call through to super.onResume()",
            "type": "android.app.CustomNotCalledException"
          }
        ],
        "message": "Unable to resume activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2}: android.app.SuperNotCalledException: Activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2} did not call through to super.onResume()",
        "type": "java.lang.RuntimeException"
      },
      "threads": [
        {
          "frames": [
            {
              "className": "dalvik.system.NativeStart",
              "fileName": "NativeStart.java",
              "lineNumber": -2,
              "methodName": "run"
            }
          ],
          "id": 369,
          "name": "Binder_3"
        },
        {
          "frames": [
            {
              "className": "dalvik.system.NativeStart",
              "fileName": "NativeStart.java",
              "lineNumber": -2,
              "methodName": "run"
            }
          ],
          "id": 345,
          "name": "Compiler"
        }
      ]

    }
  ]
}'

上傳 Breakpad 損毀記錄檔和 Minidump

您可以上傳 Android 和 Windows 的自定義 Breakpad 損毀。 例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
      "type": "managedError",
      "id": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
      "userId": "TestID",
      "processId": 9448,
      "processName": "Contoso.UWP.Puppet.exe",
      "fatal": true,
      "timestamp": "2019-10-08T06:22:23.530Z",
      "architecture": "X64",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "sid": "d4608adf-83b9-4f69-90ad-8bb0234080a7",
      "device": {
        "sdkName": "appcenter.custom",
        "sdkVersion": "2.4.1-SNAPSHOT",
        "model": "Parallels Virtual Platform",
        "oemName": "Parallels Software International Inc.",
        "osName": "WINDOWS",
        "osVersion": "10.0.18363",
        "osBuild": "10.0.18363.418",
        "locale": "en-US",
        "timeZoneOffset": -300,
        "screenSize": "4608x2470",
        "appVersion": "1.0",
        "appBuild": "1.0",
        "appNamespace": "10805zumoTestUser.AppCenter-Contoso.UWP.Puppet",
        "carrierCountry": "us",
        "wrapperSdkName": "custom.ndk"
      },
      "exception": {
        "type": "minidump",
        "wrapperSdkName": "custom.ndk"
      }
    },
    {
      "contentType": "application/octet-stream",
      "errorId": "00aa00aa-bb11-cc22-dd33-44ee44ee44ee",
      "fileName": "minidump.dmp",
      "id": "7b975468-5656-40a5-8242-c1907b26fc31",
      "sid": "03693776-cdd4-46b8-bbda-12af457f1732",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "type": "errorAttachment",
       "device": {
        "sdkName": "appcenter.custom",
        "sdkVersion": "2.4.1-SNAPSHOT",
        "model": "Parallels Virtual Platform",
        "oemName": "Parallels Software International Inc.",
        "osName": "WINDOWS",
        "osVersion": "10.0.18363",
        "osBuild": "10.0.18363.418",
        "locale": "en-US",
        "timeZoneOffset": -300,
        "screenSize": "4608x2470",
        "appVersion": "1.0",
        "appBuild": "1.0",
        "appNamespace": "10805zumoTestUser.AppCenter-Contoso.UWP.Puppet",
        "carrierCountry": "us",
        "wrapperSdkName": "custom.ndk"
      },
      "data": "<base64 encoded minidump>"
    }
  ]
}'

警示

若要上傳 Breakpad 當機, wrapperSdkName 字段必須設定為 「custom.ndk」,而且您必須將迷你傾印檔案附加為損毀報表的附件。 瞭解如何在此頁面的 附件區段中傳送附件

若要符號化當機,您必須透過 CLI 或 API 根據我們的 API 檔上傳符號。如果您使用 Breakpad 搭配 Android,則支援我們的 Android NDK 檔中 指定的這兩個選項;如果您搭配 Windows 使用 Breakpad,則僅支援選項 2:「上傳斷板符號」。

注意

如果您要從 macOS 上傳符號,則必須清除任何無關資料夾的符號,例如,產生__MACOS並刪除此專案,您可以使用 zip -d <symbols.zip> __MACOSX/\*

上傳錯誤報告

目前只有 Android、Xamarin、Unity、UWP、WPF 和 WinForms 應用程式才支援已處理的錯誤。 若要上傳錯誤報告,請確定記錄類型已設定為 「handledError」。。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
      "type": "handledError",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "id": "118dee14-9193-4ac3-9ef0-f6c11b43f2c4",
      "device": {
        "appVersion": "11.0",
        "appBuild": "1",
        "sdkName": "custom.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      },
      "userId": "TestID",
      "exception": {
        "type": "System.IO.IOException",
        "message": "Server did not respond",
        "stackTrace": "  at Contoso.Forms.Puppet.FakeService+<>c.<DoStuffInBackground>b__0_0 () [0x00000] in <7ad93f134a5d4c00a8db8be9aa9c0f76>:0 \n  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Threading.Tasks.Task.Execute () [0x00010] in <b38d4262627948c1b945a72f56ce6466>:0 \n--- End of stack trace from previous location where exception was thrown ---\n  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <b38d4262627948c1b945a72f56ce6466>:0",
        "innerExceptions": [
          {
            "type": "System.IO.IOException",
            "message": "Network down",
            "stackTrace": "  at Contoso.Forms.Demo.CrashesContentPage.SendHttp () [0x00002] in <4fd9174f6e18457b9721bfba2cd78098>:0 ",
            "wrapperSdkName": "appcenter.xamarin"
          },
          {
            "type": "System.ArgumentException",
            "message": "Invalid parameter",
            "innerExceptions": [
              {
                "type": "System.ArgumentOutOfRangeException",
                "message": "It is over 9000!",
                "stackTrace": "  at Contoso.Forms.Demo.CrashesContentPage.ValidateLength () [0x00002] in <4fd9174f6e18457b9721bfba2cd78098>:0 ",
              }
            ],
          }
        ],
      }
    }
  ]
}'

上傳附件

所有附件都必須與當機報告相關聯。 您可以在一個呼叫或兩個不同的呼叫中上傳具有當機報表的附件。

附件特定屬性:

  • contentType:具有內容類型的必要字串,例如文字的 “text/plain”。 您可以在這裡找到支援的型別範例
  • data:數據編碼為base 64的必要字串
  • errorId:包含附件相關聯錯誤報告之唯一標識符的必要字串
  • fileName:NDK 損毀的必要字串,設定為 “minidump.dmp”

注意

附件的大小限制目前為 7 MB。 嘗試傳送較大的附件將觸發錯誤。

以下是在一次呼叫中上傳當機報告和附件的範例。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: <app secret>' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "timestamp": "2019-10-01T02:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "id": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "fatal": true,
      "processName": "com.microsoft.appcenter.sasquatch.project",
      "device": {
        "appVersion": "13.0",
        "appBuild": "1",
        "sdkName": "appcenter.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      },
      "userId": "118dee14",
      "fatal": true,
      "exception": {
          "type": "CustomerIssue",
          "frames": []
      }
    },
    {
      "type": "errorAttachment",
      "contentType": "text/plain",
      "timestamp": "2019-10-01T02:22:23.516Z",
      "data": "aGVsbG8=",
      "errorId": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "id": "7caaea8e-dab1-4588-993c-95de2d9a4fd1",
      "device": {
        "appVersion": "13.0",
        "appBuild": "1",
        "sdkName": "appcenter.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      }
    }
  ]
}'