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.
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.
# 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'
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
# 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
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)
# 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
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)
# Install pidcat
pip install pidcat
# Stream logs for package
pidcat com.yourapp.id
# With tag filter
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
# 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"
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:
# iOS - Only your app
--predicate 'process == "YourApp" AND messageType >= info'# Android - Only your package
adb logcat --pid=$(adb shell pidof com.yourapp.id)