ios-android-logs by cap-go/capacitor-skills
npx skills add https://github.com/cap-go/capacitor-skills --skill ios-android-logs关于在 iOS 和 Android 上查看和过滤设备日志的完整指南。
# iOS - 从已连接的设备流式传输日志
xcrun devicectl device log stream --device <UUID>
# iOS - 从模拟器流式传输
xcrun simctl spawn booted log stream
# Android - 流式传输所有日志
adb logcat
# Android - 按包名过滤
adb logcat --pid=$(adb shell pidof com.yourapp.id)
process:YourAppsubsystem:com.yourapp"error"广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 列出已连接的设备
xcrun devicectl list devices
# 从特定设备流式传输日志
xcrun devicectl device log stream --device <DEVICE_UUID>
# 使用谓词过滤器流式传输
xcrun devicectl device log stream --device <DEVICE_UUID> \
--predicate 'process == "YourApp"'
# 流式传输特定日志级别
xcrun devicectl device log stream --device <DEVICE_UUID> \
--level error
# 保存到文件
xcrun devicectl device log stream --device <DEVICE_UUID> \
--predicate 'process == "YourApp"' > app_logs.txt
# 从已启动的模拟器流式传输日志
xcrun simctl spawn booted log stream
# 按进程过滤
xcrun simctl spawn booted log stream --predicate 'process == "YourApp"'
# 按子系统过滤
xcrun simctl spawn booted log stream --predicate 'subsystem == "com.yourapp"'
# 仅显示错误
xcrun simctl spawn booted log stream --level error
# 组合过滤器
xcrun simctl spawn booted log stream \
--predicate 'process == "YourApp" AND messageType == error'
# 进程名称
--predicate 'process == "YourApp"'
# 包含文本
--predicate 'eventMessage contains "error"'
# 子系统
--predicate 'subsystem == "com.yourapp.plugin"'
# 类别
--predicate 'category == "network"'
# 日志级别
--predicate 'messageType == error'
# 组合条件
--predicate 'process == "YourApp" AND messageType >= error'
# 基于时间(最近5分钟)
--predicate 'timestamp > now - 5m'
| 级别 | 描述 |
|---|---|
default | 默认消息 |
info | 信息性消息 |
debug | 调试消息(默认隐藏) |
error | 错误条件 |
fault | 故障/严重错误 |
# 基本日志流
adb logcat
# 先清除日志,然后流式传输
adb logcat -c && adb logcat
# 按标签过滤
adb logcat -s MyTag:D
# 按优先级过滤
adb logcat *:E # 仅错误及以上级别
# 按包名过滤
adb logcat --pid=$(adb shell pidof com.yourapp.id)
# 按多个标签过滤
adb logcat -s "MyPlugin:D" "Capacitor:I"
# 保存到文件
adb logcat > logs.txt
# 保存到文件并包含时间戳
adb logcat -v time > logs.txt
package:com.yourapptag:MyPluginlevel:error# 安装 pidcat
pip install pidcat
# 为指定包流式传输日志
pidcat com.yourapp.id
# 使用标签过滤器
pidcat -t MyPlugin com.yourapp.id
| 字母 | 优先级 |
|---|---|
| V | 详细 |
| D | 调试 |
| I | 信息 |
| W | 警告 |
| E | 错误 |
| F | 致命 |
| S | 静默 |
# 不同的输出格式
adb logcat -v brief # 默认
adb logcat -v process # 仅进程ID
adb logcat -v tag # 仅标签
adb logcat -v time # 包含时间戳
adb logcat -v threadtime # 包含线程和时间
adb logcat -v long # 所有元数据
# 彩色输出
adb logcat -v color
# 显示最近的日志(最后 N 行)
adb logcat -d -t 100
# 显示自时间戳以来的日志
adb logcat -v time -T "01-25 10:00:00.000"
# Capacitor 核心日志
adb logcat -s "Capacitor:*"
# 插件特定日志
adb logcat -s "CapacitorNativeBiometric:*"
# WebView 日志(JavaScript 控制台)
adb logcat -s "chromium:*"
# JavaScript 错误
adb logcat | grep -i "js error\|uncaught"
# 崩溃日志
adb logcat | grep -iE "fatal|crash|exception"
# 网络日志
adb logcat -s "OkHttp:*" "NetworkSecurityConfig:*"
# 从设备复制崩溃日志
xcrun devicectl device copy crashlog --device <UUID> ./crashes/
# 在 Console.app 中查看
# 用户诊断报告部分
# 或者在以下位置查找:
# 设备:设置 > 隐私 > 分析与改进 > 分析数据
# Mac:~/Library/Logs/DiagnosticReports/
# 获取墓碑文件(原生崩溃)
adb shell cat /data/tombstones/tombstone_00
# 获取 ANR 跟踪信息
adb pull /data/anr/traces.txt
# 获取错误报告(全面)
adb bugreport > bugreport.zip
使用 MCP 工具以编程方式获取日志:
// 用于获取 iOS 日志的 MCP 工具示例
const logs = await mcp.ios.streamLogs({
device: 'booted',
predicate: 'process == "YourApp"',
level: 'debug',
});
// 用于 Android 日志的 MCP 工具示例
const androidLogs = await mcp.android.logcat({
package: 'com.yourapp.id',
level: 'D',
});
# iOS - JavaScript 控制台日志
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "JS:"'
# Android - WebView 控制台
adb logcat chromium:I *:S | grep "console"
# iOS
xcrun simctl spawn booted log stream \
--predicate 'subsystem == "com.apple.network"'
# Android
adb logcat -s "NetworkSecurityConfig:*" "OkHttp:*"
# iOS - 内存压力
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "memory"'
# Android - 内存信息
adb shell dumpsys meminfo com.yourapp.id
iOS:
Android:
adb devices 以验证连接adb kill-server && adb start-server使用过滤器:
# iOS - 仅您的应用
--predicate 'process == "YourApp" AND messageType >= info'
# Android - 仅您的包
adb logcat --pid=$(adb shell pidof com.yourapp.id)
iOS:调试日志默认隐藏
# 启用调试日志
xcrun simctl spawn booted log stream --level debug
Android:确保日志级别设置正确
Log.d("Tag", "Debug message") // D 级别
每周安装次数
86
仓库
GitHub 星标数
18
首次出现
2026年1月25日
安全审计
安装于
claude-code61
opencode60
cursor58
codex57
gemini-cli54
github-copilot53
Complete guide to viewing and filtering device logs on iOS and Android.
# iOS - Stream logs from connected device
xcrun devicectl device log stream --device <UUID>
# iOS - Stream from simulator
xcrun simctl spawn booted log stream
# Android - Stream all logs
adb logcat
# Android - Filter by package
adb logcat --pid=$(adb shell pidof com.yourapp.id)
process:YourAppsubsystem:com.yourapp"error"# List connected devices
xcrun devicectl list devices
# Stream logs from specific device
xcrun devicectl device log stream --device <DEVICE_UUID>
# Stream with predicate filter
xcrun devicectl device log stream --device <DEVICE_UUID> \
--predicate 'process == "YourApp"'
# Stream specific log levels
xcrun devicectl device log stream --device <DEVICE_UUID> \
--level error
# Save to file
xcrun devicectl device log stream --device <DEVICE_UUID> \
--predicate 'process == "YourApp"' > app_logs.txt
# Stream logs from booted simulator
xcrun simctl spawn booted log stream
# Filter by process
xcrun simctl spawn booted log stream --predicate 'process == "YourApp"'
# Filter by subsystem
xcrun simctl spawn booted log stream --predicate 'subsystem == "com.yourapp"'
# Show only errors
xcrun simctl spawn booted log stream --level error
# Combine filters
xcrun simctl spawn booted log stream \
--predicate 'process == "YourApp" AND messageType == error'
# 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'
| Level | Description |
|---|---|
default | Default messages |
info | Informational |
debug | Debug (hidden by default) |
error | Error conditions |
fault | Fault/critical |
# Basic log stream
adb logcat
# Clear logs first, then stream
adb logcat -c && adb logcat
# Filter by tag
adb logcat -s MyTag:D
# Filter by priority
adb logcat *:E # Only errors and above
# Filter by package name
adb logcat --pid=$(adb shell pidof com.yourapp.id)
# Filter by multiple tags
adb logcat -s "MyPlugin:D" "Capacitor:I"
# Save to file
adb logcat > logs.txt
# Save to file with timestamp
adb logcat -v time > logs.txt
package:com.yourapptag:MyPluginlevel:error# Install pidcat
pip install pidcat
# Stream logs for package
pidcat com.yourapp.id
# With tag filter
pidcat -t MyPlugin com.yourapp.id
| Letter | Priority |
|---|---|
| V | Verbose |
| D | Debug |
| I | Info |
| W | Warn |
| E | Error |
| F | Fatal |
| S | Silent |
# Different output formats
adb logcat -v brief # Default
adb logcat -v process # PID only
adb logcat -v tag # Tag only
adb logcat -v time # With timestamp
adb logcat -v threadtime # With thread and time
adb logcat -v long # All metadata
# Colorized output
adb logcat -v color
# Show recent logs (last N lines)
adb logcat -d -t 100
# Show logs since timestamp
adb logcat -v time -T "01-25 10:00:00.000"
# Capacitor core logs
adb logcat -s "Capacitor:*"
# Plugin-specific logs
adb logcat -s "CapacitorNativeBiometric:*"
# WebView logs (JavaScript console)
adb logcat -s "chromium:*"
# JavaScript errors
adb logcat | grep -i "js error\|uncaught"
# Crash logs
adb logcat | grep -iE "fatal|crash|exception"
# Network logs
adb logcat -s "OkHttp:*" "NetworkSecurityConfig:*"
# Copy crash logs from device
xcrun 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/
# Get tombstone (native crash)
adb shell cat /data/tombstones/tombstone_00
# Get ANR traces
adb pull /data/anr/traces.txt
# Get bugreport (comprehensive)
adb bugreport > bugreport.zip
Use MCP tools to fetch logs programmatically:
// Example MCP tool for fetching iOS logs
const logs = await mcp.ios.streamLogs({
device: 'booted',
predicate: 'process == "YourApp"',
level: 'debug',
});
// Example MCP tool for Android logs
const androidLogs = await mcp.android.logcat({
package: 'com.yourapp.id',
level: 'D',
});
# iOS - JavaScript console logs
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "JS:"'
# Android - WebView console
adb logcat chromium:I *:S | grep "console"
# iOS
xcrun simctl spawn booted log stream \
--predicate 'subsystem == "com.apple.network"'
# Android
adb logcat -s "NetworkSecurityConfig:*" "OkHttp:*"
# iOS - Memory pressure
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "memory"'
# Android - Memory info
adb shell dumpsys meminfo com.yourapp.id
iOS :
Android :
adb devices to verify connectionadb kill-server && adb start-serverUse filters:
# iOS - Only your app
--predicate 'process == "YourApp" AND messageType >= info'
# Android - Only your package
adb logcat --pid=$(adb shell pidof com.yourapp.id)
iOS : Debug logs are hidden by default
# Enable debug logs
xcrun simctl spawn booted log stream --level debug
Android : Ensure log level is set correctly
Log.d("Tag", "Debug message") // D level
Weekly Installs
86
Repository
GitHub Stars
18
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code61
opencode60
cursor58
codex57
gemini-cli54
github-copilot53
Kotlin 开发模式与最佳实践 | 构建健壮高效应用程序的惯用指南
1,000 周安装