Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NativePHP/mobile-air/llms.txt
Use this file to discover all available pages before exploring further.
Streams Laravel application logs in real-time from a running Android application.
Syntax
What it does
- Connects to running Android app via
adb
- Tails the Laravel log file from the app’s storage
- Displays log entries in real-time
- Press Ctrl+C to stop
Examples
Tail logs from running app
Output:
Tailing Android logs for app: com.example.myapp
Press Ctrl+C to stop...
[2024-02-28 10:30:15] local.INFO: User logged in
[2024-02-28 10:30:22] local.DEBUG: Processing order #123
[2024-02-28 10:30:25] local.ERROR: Payment failed: Connection timeout
Requirements
ADB (Android Debug Bridge)
Must be installed and in PATH:
# Check if installed
adb version
# macOS
brew install android-platform-tools
# Ubuntu/Debian
sudo apt install android-tools-adb
# Windows - comes with Android Studio
Running Android app
The app must be:
- Installed on connected device/emulator
- Currently running
- Built with debuggable flag enabled
App ID
NATIVEPHP_APP_ID must be set in .env:
NATIVEPHP_APP_ID=com.example.myapp
How it works
Uses adb shell run-as to access the app’s private storage:
adb shell run-as com.example.myapp \
tail -f app_storage/persisted_data/storage/logs/laravel.log
This reads from Laravel’s standard log location within the app’s sandboxed filesystem.
Common workflows
Run and monitor logs
# Terminal 1: Run the app
php artisan native:run android
# Terminal 2: Tail logs
php artisan native:tail
Debug with watch and logs
# Terminal 1: Run with watch
php artisan native:run android --watch
# Terminal 2: Tail logs
php artisan native:tail
# Terminal 3: Edit code
vim app/Http/Controllers/HomeController.php
Now you see:
- Code changes (Terminal 1)
- Log output (Terminal 2)
- Hot reload updates
Filter logs
Pipe to grep for specific messages:
php artisan native:tail | grep ERROR
php artisan native:tail | grep "User logged"
Logging best practices
Use Laravel’s logging in your mobile app:
use Illuminate\Support\Facades\Log;
// Different log levels
Log::debug('Debugging information');
Log::info('User action', ['user_id' => 123]);
Log::warning('Something unusual happened');
Log::error('An error occurred', ['exception' => $e]);
Add context
Include useful context:
Log::info('API request', [
'endpoint' => $url,
'method' => 'POST',
'duration' => $duration,
'response_code' => $response->status(),
]);
$start = microtime(true);
// Your code here
$duration = microtime(true) - $start;
Log::debug('Operation completed', [
'operation' => 'process_payment',
'duration_ms' => round($duration * 1000, 2),
]);
Troubleshooting
”NATIVEPHP_APP_ID is not set”
Add to .env:
NATIVEPHP_APP_ID=com.example.myapp
“adb: command not found”
Install Android platform tools:
# macOS
brew install android-platform-tools
# Or add to PATH
export PATH=$PATH:$HOME/Library/Android/sdk/platform-tools
“device offline” or “no devices”
Check device connection:
Should show:
List of devices attached
emulator-5554 device
If offline:
adb kill-server
adb start-server
adb devices
“run-as: package not debuggable”
App must be built with debug flag. Use:
php artisan native:run android --build=debug
Release builds are not debuggable.
No log output
Check:
- App is running:
adb shell ps | grep your.app.id
- Log file exists: Trigger an action that logs
- Log level: Check
config/logging.php level
Alternative: Use Logcat
For system-level logs:
adb logcat | grep "your.app.id"
This shows all Android system logs, not just Laravel logs.
iOS equivalent
For iOS, use Xcode Console:
- Run app with Xcode or
native:run ios
- Open Xcode
- Window > Devices and Simulators
- Select your device/simulator
- Click “Open Console” button
- Filter by app name
Or use command line:
# iOS Simulator
xcrun simctl spawn booted log stream --predicate 'processImagePath contains "YourApp"'
# Physical device (requires macOS)
log stream --device --predicate 'processImagePath contains "YourApp"'
See also