Ios Android Logs

cap-go/capgo-skills/skills/ios-android-logs

作者 cap-go2cfb277a1488無授權條款72 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Guide to accessing device logs on iOS and Android for Capacitor apps. Covers command-line tools, GUI applications, filtering, and real-time streaming. Use this skill when users need to view device logs for debugging.

AI 產生的概覽

針對 Capacitor 應用程式的 iOS 與 Android 裝置日誌檢視與篩選指南。

功能
此技能是一份關於在 iOS 與 Android 上存取裝置日誌的參考指南,主要針對 Capacitor 應用程式。內容說明 xcrun devicectl、xcrun simctl、adb logcat 等命令列工具,以及 Console.app 與 Android Studio Logcat 等圖形介面方式,並涵蓋篩選、日誌層級、當機日誌取得與即時串流輸出。此外也包含疑難排解步驟、最佳實務,以及以程式化方式取得日誌的 MCP 呼叫範例。
適用情境
當你需要檢視裝置日誌、偵錯當機、依應用程式或套件名稱篩選日誌,或即時串流檢視日誌時使用。也適用於有人詢問如何在 iOS 或 Android 上查看日誌的情況。
執行需求
需要可用的 iOS 與 Android 工具鏈:Xcode 命令列工具(xcrun devicectl、xcrun simctl)與 Android 平台工具(adb),並連接實機或模擬器。文中也提到選用工具,包括 Console.app、Android Studio、Xcode、以 pip 安裝的 pidcat,以及 MCP 工具。此技能未附帶指令碼,僅為說明文件。

iOS and Android Device Logs

Complete guide to viewing and filtering device logs on iOS and Android.

When to Use This Skill

  • User needs to see device logs
  • User is debugging crashes
  • User wants to filter logs by app
  • User needs real-time log streaming
  • User asks "how to see logs"

Quick Commands

bash
# iOS - Stream logs from connected devicexcrun devicectl device log stream --device <UUID>
# iOS - Stream from simulatorxcrun simctl spawn booted log stream
# Android - Stream all logsadb logcat
# Android - Filter by packageadb logcat --pid=$(adb shell pidof com.yourapp.id)

iOS Logs

Method 1: Console.app (GUI)

  1. Open Console.app (Applications > Utilities)
  2. Select your device in sidebar
  3. Click "Start Streaming"
  4. Use search to filter:
    • By process: process:YourApp
    • By subsystem: subsystem:com.yourapp
    • By message: "error"

Method 2: devicectl (CLI - Recommended)

bash
# List connected devicesxcrun devicectl list devices
# Stream logs from specific devicexcrun devicectl device log stream --device <DEVICE_UUID>
# Stream with predicate filterxcrun devicectl device log stream --device <DEVICE_UUID> \  --predicate 'process == "YourApp"'
# Stream specific log levelsxcrun devicectl device log stream --device <DEVICE_UUID> \  --level error
# Save to filexcrun devicectl device log stream --device <DEVICE_UUID> \  --predicate 'process == "YourApp"' > app_logs.txt

Method 3: simctl for Simulators

bash
# Stream logs from booted simulatorxcrun simctl spawn booted log stream
# Filter by processxcrun simctl spawn booted log stream --predicate 'process == "YourApp"'
# Filter by subsystemxcrun simctl spawn booted log stream --predicate 'subsystem == "com.yourapp"'
# Show only errorsxcrun simctl spawn booted log stream --level error
# Combine filtersxcrun simctl spawn booted log stream \  --predicate 'process == "YourApp" AND messageType == error'

Method 4: Xcode Device Logs

  1. Window > Devices and Simulators
  2. Select device
  3. Click "Open Console"
  4. Or: View device logs for crash reports

iOS Log Predicate Examples

bash
# Process name--predicate 'process == "YourApp"'
# Contains text--predicate 'eventMessage contains "error"'
# Subsystem--predicate 'subsystem == "com.yourapp.plugin"'
# Category--predicate 'category == "network"'
# Log level--predicate 'messageType == error'
# Combined--predicate 'process == "YourApp" AND messageType >= error'
# Time-based (last 5 minutes)--predicate 'timestamp > now - 5m'

iOS Log Levels

LevelDescription
defaultDefault messages
infoInformational
debugDebug (hidden by default)
errorError conditions
faultFault/critical

Android Logs

Method 1: adb logcat (CLI)

bash
# Basic log streamadb logcat
# Clear logs first, then streamadb logcat -c && adb logcat
# Filter by tagadb logcat -s MyTag:D
# Filter by priorityadb logcat *:E  # Only errors and above
# Filter by package nameadb logcat --pid=$(adb shell pidof com.yourapp.id)
# Filter by multiple tagsadb logcat -s "MyPlugin:D" "Capacitor:I"
# Save to fileadb logcat > logs.txt
# Save to file with timestampadb logcat -v time > logs.txt

Method 2: Android Studio Logcat (GUI)

  1. View > Tool Windows > Logcat
  2. Use filter dropdown:
    • Package: package:com.yourapp
    • Tag: tag:MyPlugin
    • Level: level:error
  3. Create saved filters for quick access

Method 3: pidcat (Better CLI Tool)

bash
# Install pidcatpip install pidcat
# Stream logs for packagepidcat com.yourapp.id
# With tag filterpidcat -t MyPlugin com.yourapp.id

Android Log Priority Levels

LetterPriority
VVerbose
DDebug
IInfo
WWarn
EError
FFatal
SSilent

adb logcat Format Options

bash
# Different output formatsadb logcat -v brief     # Defaultadb logcat -v process   # PID onlyadb logcat -v tag       # Tag onlyadb logcat -v time      # With timestampadb logcat -v threadtime # With thread and timeadb logcat -v long      # All metadata
# Colorized outputadb logcat -v color
# Show recent logs (last N lines)adb logcat -d -t 100
# Show logs since timestampadb logcat -v time -T "01-25 10:00:00.000"

Common Android Filters

bash
# Capacitor core logsadb logcat -s "Capacitor:*"
# Plugin-specific logsadb logcat -s "CapacitorNativeBiometric:*"
# WebView logs (JavaScript console)adb logcat -s "chromium:*"
# JavaScript errorsadb logcat | grep -i "js error\|uncaught"
# Crash logsadb logcat | grep -iE "fatal|crash|exception"
# Network logsadb logcat -s "OkHttp:*" "NetworkSecurityConfig:*"

Viewing Crash Logs

iOS Crash Logs

bash
# Copy crash logs from devicexcrun devicectl device copy crashlog --device <UUID> ./crashes/
# View in Console.app# User Diagnostics Reports section
# Or find at:# Device: Settings > Privacy > Analytics & Improvements > Analytics Data# Mac: ~/Library/Logs/DiagnosticReports/

Android Crash Logs

bash
# Get tombstone (native crash)adb shell cat /data/tombstones/tombstone_00
# Get ANR tracesadb pull /data/anr/traces.txt
# Get bugreport (comprehensive)adb bugreport > bugreport.zip

MCP Integration

Use MCP tools to fetch logs programmatically:

typescript
// Example MCP tool for fetching iOS logsconst logs = await mcp.ios.streamLogs({  device: 'booted',  predicate: 'process == "YourApp"',  level: 'debug',});
// Example MCP tool for Android logsconst androidLogs = await mcp.android.logcat({  package: 'com.yourapp.id',  level: 'D',});

Log Parsing Tips

Extract JavaScript Errors

bash
# iOS - JavaScript console logsxcrun simctl spawn booted log stream \  --predicate 'eventMessage contains "JS:"'
# Android - WebView consoleadb logcat chromium:I *:S | grep "console"

Filter Network Requests

bash
# iOSxcrun simctl spawn booted log stream \  --predicate 'subsystem == "com.apple.network"'
# Androidadb logcat -s "NetworkSecurityConfig:*" "OkHttp:*"

Monitor Memory

bash
# iOS - Memory pressurexcrun simctl spawn booted log stream \  --predicate 'eventMessage contains "memory"'
# Android - Memory infoadb shell dumpsys meminfo com.yourapp.id

Troubleshooting

Issue: No Logs Showing

iOS:

  • Ensure device is trusted: Xcode > Window > Devices
  • Try restarting log stream
  • Check Console.app filters

Android:

  • Enable USB debugging
  • Run adb devices to verify connection
  • Try adb kill-server && adb start-server

Issue: Too Many Logs

Use filters:

bash
# iOS - Only your app--predicate 'process == "YourApp" AND messageType >= info'
# Android - Only your packageadb logcat --pid=$(adb shell pidof com.yourapp.id)

Issue: Missing Debug Logs

iOS: Debug logs are hidden by default

bash
# Enable debug logsxcrun simctl spawn booted log stream --level debug

Android: Ensure log level is set correctly

kotlin
Log.d("Tag", "Debug message")  // D level

Best Practices

  1. Use structured logging - Include context in log messages
  2. Add timestamps - Helps correlate events
  3. Filter early - Don't stream all logs
  4. Save important logs - Redirect to file for later analysis
  5. Use log levels appropriately - Debug for dev, error for production

Resources

來源與署名

來源:cap-go/capgo-skills位於skills/ios-android-logs提交2cfb277

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架