| name | ios-android-logs |
| description | 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. |
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
xcrun devicectl device log stream --device <UUID>
xcrun simctl spawn booted log stream
adb logcat
adb logcat --pid=$(adb shell pidof com.yourapp.id)
iOS Logs
Method 1: Console.app (GUI)
- Open Console.app (Applications > Utilities)
- Select your device in sidebar
- Click "Start Streaming"
- Use search to filter:
- By process:
process:YourApp
- By subsystem:
subsystem:com.yourapp
- By message:
"error"
Method 2: devicectl (CLI - Recommended)
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
Method 3: simctl for Simulators
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'
Method 4: Xcode Device Logs
- Window > Devices and Simulators
- Select device
- Click "Open Console"
- Or: View device logs for crash reports
iOS Log Predicate Examples
--predicate 'process == "YourApp"'
--predicate 'eventMessage contains "error"'
--predicate 'subsystem == "com.yourapp.plugin"'
--predicate 'category == "network"'
--predicate 'messageType == error'
--predicate 'process == "YourApp" AND messageType >= error'
--predicate 'timestamp > now - 5m'
iOS Log Levels
| Level | Description |
|---|
default | Default messages |
info | Informational |
debug | Debug (hidden by default) |
error | Error conditions |
fault | Fault/critical |
Android Logs
Method 1: adb logcat (CLI)
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
Method 2: Android Studio Logcat (GUI)
- View > Tool Windows > Logcat
- Use filter dropdown:
- Package:
package:com.yourapp
- Tag:
tag:MyPlugin
- Level:
level:error
- Create saved filters for quick access
Method 3: pidcat (Better CLI Tool)
pip install pidcat
pidcat com.yourapp.id
pidcat -t MyPlugin com.yourapp.id
Android Log Priority Levels
| Letter | Priority |
|---|
| V | Verbose |
| D | Debug |
| I | Info |
| W | Warn |
| E | Error |
| F | Fatal |
| S | Silent |
adb logcat Format Options
adb logcat -v brief
adb logcat -v process
adb logcat -v tag
adb logcat -v time
adb logcat -v threadtime
adb logcat -v long
adb logcat -v color
adb logcat -d -t 100
adb logcat -v time -T "01-25 10:00:00.000"
Common Android Filters
adb logcat -s "Capacitor:*"
adb logcat -s "CapacitorNativeBiometric:*"
adb logcat -s "chromium:*"
adb logcat | grep -i "js error\|uncaught"
adb logcat | grep -iE "fatal|crash|exception"
adb logcat -s "OkHttp:*" "NetworkSecurityConfig:*"
Viewing Crash Logs
iOS Crash Logs
xcrun devicectl device copy crashlog --device <UUID> ./crashes/
Android Crash Logs
adb shell cat /data/tombstones/tombstone_00
adb pull /data/anr/traces.txt
adb bugreport > bugreport.zip
MCP Integration
Use MCP tools to fetch logs programmatically:
const logs = await mcp.ios.streamLogs({
device: 'booted',
predicate: 'process == "YourApp"',
level: 'debug',
});
const androidLogs = await mcp.android.logcat({
package: 'com.yourapp.id',
level: 'D',
});
Log Parsing Tips
Extract JavaScript Errors
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "JS:"'
adb logcat chromium:I *:S | grep "console"
Filter Network Requests
xcrun simctl spawn booted log stream \
--predicate 'subsystem == "com.apple.network"'
adb logcat -s "NetworkSecurityConfig:*" "OkHttp:*"
Monitor Memory
xcrun simctl spawn booted log stream \
--predicate 'eventMessage contains "memory"'
adb 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:
--predicate 'process == "YourApp" AND messageType >= info'
adb logcat --pid=$(adb shell pidof com.yourapp.id)
Issue: Missing Debug Logs
iOS: Debug logs are hidden by default
xcrun simctl spawn booted log stream --level debug
Android: Ensure log level is set correctly
Log.d("Tag", "Debug message")
Best Practices
- Use structured logging - Include context in log messages
- Add timestamps - Helps correlate events
- Filter early - Don't stream all logs
- Save important logs - Redirect to file for later analysis
- Use log levels appropriately - Debug for dev, error for production
Resources