Installation
composer require arcanedev/log-viewer
Publish the config (optional, but recommended for customization):
php artisan vendor:publish --provider="ARCANE\LogViewer\LogViewerServiceProvider" --tag="config"
First Use Case
Access the log viewer at /log-viewer (default route). No additional configuration is required for basic usage.
Where to Look First
config/log-viewer.php (customize paths, middleware, or log levels)._docs/1.Installation-and-Setup.md for setup specifics./api/log-viewer for programmatic access (e.g., from frontend apps or scripts).Viewing Logs
/log-viewer for an interactive log viewer with pagination, filtering (by date/level), and search./api/log-viewer with query params:
curl -X GET "/api/log-viewer?level=error&date=2024-03-18&limit=50"
Response: JSON array of log entries with metadata (level, date, message).Filtering and Search
debug, error).?search=error&level=critical).Log Management
curl -X DELETE "/api/log-viewer?ids[]=123&ids[]=456"
.txt or .json file via the UI download button or API:
curl -X GET "/api/log-viewer/export?format=json"
Custom Log Paths
config/log-viewer.php:
'paths' => [
storage_path('logs/custom'),
database_path('logs'),
],
local and production logs).Integration with Existing Systems
error level) and trigger alerts.curl -X GET "/api/log-viewer/export?format=json" --output deployment-logs.json
Middleware and Access Control
web middleware group in app/Http/Kernel.php:
'log-viewer' => [
\App\Http\Middleware\CheckAdmin::class,
],
config/log-viewer.php:
'middleware' => ['auth', 'verified'],
Permission Issues
chmod -R 775 storage/
chown -R www-data:www-data storage/ # Adjust user/group as needed
Large Log Files
php.ini:
memory_limit = 256M
chunk parameter in the API to paginate results:
curl "/api/log-viewer?chunk=1000"
config/log-viewer.php to limit the number of logs loaded at once:
'per_page' => 1000,
Custom Log Levels Not Displaying
alert) appear as unknown in the UI.config/log-viewer.php:
'levels' => [
'debug' => ['name' => 'Debug', 'icon' => 'bug'],
'alert' => ['name' => 'Alert', 'icon' => 'exclamation-triangle', 'color' => 'red'],
],
Route Conflicts
/log-viewer route not found or conflicts with existing routes.routes/web.php:
ARCANE\LogViewer\LogViewerServiceProvider::routes(['prefix' => 'admin']);
API Rate Limiting
429 Too Many Requests.config/log-viewer.php or implement caching for frequent API calls.Localization
php artisan vendor:publish --provider="ARCANE\LogViewer\LogViewerServiceProvider" --tag="lang"
resources/lang/en/log-viewer.php.Log Level Icons
config/log-viewer.php:
'levels' => [
'error' => ['icon' => 'fire-alt'], // Replace 'times-circle'
],
Excluding Sensitive Logs
LogViewer class:
use ARCANE\LogViewer\Facades\LogViewer;
LogViewer::filter(function ($log) {
return !preg_match('/password|secret/i', $log->message);
});
Programmatic Log Access
use ARCANE\LogViewer\Facades\LogViewer;
$logs = LogViewer::getLogs(['level' => 'error', 'limit' => 10]);
Custom Storage Adapters
LogViewer\Contracts\LogStorage interface.Dark Mode Support
resources/css/log-viewer.css to match your app’s theme:
.log-viewer {
--bg-color: #1a1a1a;
--text-color: #e0e0e0;
}
Log Retention Policy
php artisan log:clean) and integrating it with LogViewer’s API to delete old logs:
curl -X DELETE "/api/log-viewer?older_than=30" # Delete logs older than 30 days
How can I help you explore Laravel packages today?