A Laravel package that integrates with the Laravel Forge API to fetch and manage application logs (laravel and nginx) from your Forge-managed sites. Simplify log retrieval and monitoring with interactive CLI commands.
With the use of AI, it is increasingly necessary to access logs remotely to speed up bug fixing.
- Interactive setup wizard to configure your Forge organization, server, and site
- Fetch application logs directly from Laravel Forge
- Fetch nginx access logs from Laravel Forge
- Fetch nginx error logs from Laravel Forge
- Customizable log file paths and filenames
- Store logs locally for analysis
- Simple artisan commands for easy integration
- PHP 8.4+
- Laravel 11.x or 12.x
You can install the package via Composer:
composer require frankflow/laravel-forge-logs --devFirst, obtain your API token from Laravel Forge:
- Log in to Laravel Forge
- Go to your account settings
- Navigate to the API section
- Generate a new API token (make sure you set the right scopes for the token)
Add the following line to your .env file:
FORGE_TOKEN=your-forge-api-token-hereRun the initialization command to configure your organization, server, and site:
php artisan forge-initThis interactive command will:
-
Automatically update your
.envfile with the configuration
Once configured, you can fetch different types of logs:
php artisan forge-fetch-logs
# or
php artisan forge-all-logsThis command will fetch Laravel application logs, Nginx access logs, and Nginx error logs in sequence.
php artisan forge-laravel-logsSaves to storage/logs/laravel.log (customizable in config).
php artisan forge-nginx-access-logsSaves to storage/logs/nginx/access.log (customizable in config).
php artisan forge-nginx-error-logsSaves to storage/logs/nginx/error.log (customizable in config).
php artisan forge-delete-logsInteractively deletes logs on the configured site via the Forge API. The command presents a menu to select which logs to delete:
Options:
Skip the confirmation prompt with --force:
php artisan forge-delete-logs --forcePublish the configuration file:
php artisan vendor:publish --tag="forge-logs-config"This will create a config/forge-logs.php file with the following structure:
return [
'forge_token' => env('FORGE_TOKEN'),
'forge_server_id' => env('FORGE_SERVER_ID'),
'forge_site_id' => env('FORGE_SITE_ID'),
'forge_organization' => env('FORGE_ORGANIZATION'),
// Customize log file paths (relative to storage_path())
'log_paths' => [
'laravel' => 'logs/laravel.log',
'nginx_access' => 'logs/nginx/access.log',
'nginx_error' => 'logs/nginx/error.log',
],
];You can customize where the logs are saved by modifying the log_paths array in config/forge-logs.php:
'log_paths' => [
'laravel' => 'logs/forge/laravel.log', // Change path
'nginx_access' => 'logs/forge/nginx-access.log', // Change path and filename
'nginx_error' => 'logs/forge/nginx-error.log', // Change path and filename
],All paths are relative to the storage_path() directory.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.




