Installation:
composer require danilovl/log-viewer-bundle
Add to config/bundles.php and run php bin/console assets:install.
Basic Configuration:
Create config/packages/danilovl_log_viewer.yaml with minimal settings:
danilovl_log_viewer:
sources:
dirs: ['%kernel.logs_dir%']
parser:
go_enabled: false
First Use Case:
Access /danilovl/log-viewer to view logs in the dashboard. No additional setup is required for default behavior.
Log Discovery & Filtering:
sources.dirs to include log directories (e.g., %kernel.logs_dir%).sources.ignore to exclude files (e.g., ['cache.log']).parser.overrides:
parser:
overrides:
'/var/log/nginx/error.log': 'nginx_error'
Real-Time Monitoring: Enable live logs with:
live_log_page:
enabled: true
interval: '3 sec'
levels: ['error', 'critical']
Access via /danilovl/log-viewer/live.
Remote Logs: Add SSH/SFTP hosts:
sources:
remote_hosts:
- name: 'prod_server'
type: 'ssh'
host: '1.2.3.4'
user: 'deploy'
ssh_key: '%kernel.project_dir%/config/ssh/id_rsa'
dirs: ['/var/www/app/var/log']
AI Integration: Configure AI chats for error logs:
ai:
button_levels: ['error', 'critical']
chats:
- { name: 'ChatGPT', url: 'https://chatgpt.com/?q={prompt}' }
Notifications: Set up notifier rules and run the watcher:
php bin/console danilovl:log-viewer:watch --interval=5
Configure transports in framework.yaml (e.g., Slack/Telegram).
symfony/notifier is installed for notifications.go_enabled: true), but verify the binary path.Resources/assets/js/./danilovl/log-viewer/api) for custom dashboards:
// Example: Fetch log entries via API
$response = $client->get('/danilovl/log-viewer/api/logs?file=/var/log/app.log');
Permissions:
chmod 644 /var/log/*.log).allow_delete/allow_download, files must be writable/readable by the web user.Go Parser:
go_binary_path). Test locally before production.Remote Hosts:
ssh2 PHP extension. Install via:
pecl install ssh2
.env or encrypted config).Caching:
cache.parser_detect_enabled if parser detection is unreliable.php bin/console cache:clear
Live Logs:
interval values (e.g., 10 sec) may cause delays. Test with 3 sec for responsiveness.live_log_page.levels to avoid noise.var/log/dev.log for parser-related issues. Override parsers explicitly if needed.yarn build --watch
Or rebuild:
yarn build
php bin/console assets:install
api_prefix in config and ensure routes are loaded (_danilovl_log_viewer in routes.yaml).Custom Parsers: Extend the parser system by creating a new parser class and registering it in the bundle’s services:
# config/services.yaml
Danilovl\LogViewerBundle\Parser\CustomParser:
tags: ['danilovl_log_viewer.parser']
Frontend Customization:
Override Vue components in templates/bundles/LogViewerBundle/ or extend via Encore:
// assets/js/app.js
import LogViewer from '@danilovl/log-viewer-bundle/js/components/LogViewer.vue';
// Extend or replace components here
Notifier Rules: Dynamically add rules via the API or CLI:
php bin/console danilovl:log-viewer:notifier:add-rule --name="DB Errors" --levels="error" --channels="chat/slack"
Dark/Light Mode: Force a theme via config:
# config/packages/danilovl_log_viewer.yaml
theme: 'dark' # or 'light'
go_enabled: true) and set max_file_size to limit memory usage.interval for critical logs (e.g., 1 sec) but increase for non-critical (e.g., 10 sec).statistic_enabled if not needed to reduce CPU load.How can I help you explore Laravel packages today?