Quick start
Get LogReader running in your Laravel application in a few steps:
- Install the package:
composer require mvd81/laravel-logreader - Publish the config:
php artisan vendor:publish --tag=logreader-config - Create an app in your LogReader dashboard
- Copy the API token and add it to your
.env:LOGREADER_ENABLED=true LOGREADER_TOKEN=your-api-token-here - Your logs will now appear in the LogReader dashboard
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=logreader-config
Add the following environment variables to your .env file:
LOGREADER_ENABLED=true
LOGREADER_TOKEN=your-api-token-here
You can find your API token in the Apps section of your dashboard after creating an app.
How it works
Once installed and configured, the package allows LogReader to securely connect to your Laravel application using your token to read, search, and filter your log files in real time.
All file access is restricted to your application's storage/logs directory. Every request is validated with your token and path traversal attacks are prevented.
Excluding log files
Although LogReader does not store your log data, your logs may contain sensitive information such as passwords, tokens, or personal data. To prevent this information from being visible to other users with access to your dashboard, you can exclude specific log files or directories.
Set the LOGREADER_EXCLUDE_LOGS environment variable with a comma-separated list of patterns:
LOGREADER_EXCLUDE_LOGS=passwords.log,private/*,*.tmp
Supported patterns:
- Exact filenames:
passwords.log - Directory paths:
private/* - Wildcards:
*.tmp,cache*
Configuration options
| Option | Environment variable | Default | Description |
|---|---|---|---|
enabled |
LOGREADER_ENABLED |
true |
Enable or disable the LogReader API |
token |
LOGREADER_TOKEN |
null |
API token for authenticating requests |
exclude_logs |
LOGREADER_EXCLUDE_LOGS |
'' |
Comma-separated list of files or patterns to exclude |