Download the PHP package mikailfaruqali/log-viewer without Composer
On this page you can find all versions of the php package mikailfaruqali/log-viewer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mikailfaruqali/log-viewer
More information about mikailfaruqali/log-viewer
Files in mikailfaruqali/log-viewer
Package log-viewer
Short Description A modern, elegant, and feature-rich log viewer for Laravel applications. Experience a beautiful glassmorphism-inspired interface that makes viewing and managing your application logs both intuitive and visually appealing.
License MIT
Homepage https://github.com/mikailfaruqali/log-viewer
Informations about the package log-viewer
๐ Snawbar Log Viewer
A modern, elegant, and feature-rich log viewer for Laravel applications. Experience a beautiful glassmorphism-inspired interface that makes viewing and managing your application logs both intuitive and visually appealing.
โจ Features
๐จ Modern UI/UX
- Glassmorphism Design: Beautiful translucent interface with backdrop blur effects
- Dark Theme: Eye-friendly dark interface perfect for development environments
- Responsive Layout: Fully responsive design that works on desktop, tablet, and mobile
- Smooth Animations: CSS transitions and hover effects for enhanced user experience
- Mobile-First: Collapsible sidebar and touch-friendly interactions on mobile devices
๐ File Management
- Smart File Detection: Automatically discovers all
.logfiles in yourstorage/logsdirectory - File Switching: Seamlessly switch between different log files with a single click
- File Deletion: Safely delete old log files directly from the interface with confirmation
- File Sorting: Log files are automatically sorted by modification time (newest first)
- File Status: Visual indicators for active/selected files
๐ Log Parsing & Display
- Dual Format Support: Parses both Laravel's classic text format and Monolog's JSON format
- JSON Log Support: Fully supports structured JSON logs โ reads
message,level_name,channel,datetime,context, andextrafields - Multi-line Support: Properly handles stack traces and multi-line log entries
- Log Levels: Color-coded log levels (debug, info, notice, warning, error, critical, alert, emergency)
- Timestamp Formatting: Human-readable timestamp display with ISO 8601 normalization
- Environment Detection: Automatically detects and displays the environment (production, local, etc.)
- Context Badges: Displays inline context badges (tenant, url, method, userId) from JSON logs
- Exception Details: Shows full exception class, message, file location, and chained
Caused byexceptions - Request Input: Renders request input payload from JSON logs in a readable pre-formatted block
๐ Enhanced Viewing Experience
- Expandable Entries: Click to expand log entries and view full messages and stack traces
- Stack Trace Viewer: Properly formatted stack trace display for debugging
- Message Truncation: Long messages are truncated with ellipsis and expandable on demand
- Empty State Handling: Graceful handling of empty log files and missing selections
- Error Recovery: Robust error handling for corrupted or unreadable log files
๐ Security & Access Control
- Authentication Required: Protected by Laravel's authentication middleware by default
- Configurable Middleware: Easily add custom authorization middleware
- CSRF Protection: All delete operations are CSRF protected
- Input Validation: Comprehensive validation for all user inputs
- Safe File Operations: Prevents directory traversal and unauthorized file access
โก Performance & Reliability
- Efficient Parsing: Optimized log parsing algorithm that handles large files
- Memory Management: Processes logs efficiently without excessive memory usage
- Error Logging: Internal errors are logged for debugging purposes
- Graceful Degradation: Continues working even when individual log files have issues
๐ ๏ธ Developer Experience
- Zero Dependencies: No external CSS or JS frameworks required
- Easy Installation: Simple Composer installation with auto-discovery
- Configurable Routes: Customize the route path and middleware
- Publishable Views: Customize the interface to match your application's design
- Clean Architecture: Well-structured codebase following Laravel conventions
๐ Installation
Requirements: PHP 8.3+ and Laravel 11+
Install the package via Composer:
The package uses Laravel's auto-discovery feature, so no additional setup is required.
โ๏ธ Configuration
Basic Configuration
The package works out-of-the-box, but you can publish the configuration file for customization:
This creates a config/snawbar-log-viewer.php file:
Advanced Configuration
Custom Route Path:
Custom Middleware:
Role-based Access:
View Customization
Publish the views to customize the interface:
This publishes views to resources/views/vendor/snawbar-log-viewer/ for customization.
๐ Usage
Accessing the Log Viewer
After installation, navigate to the configured route:
Note: You must be authenticated to access the log viewer (default middleware: ['web', 'auth'])
Interface Overview
- Sidebar: Lists all available log files, sorted by modification date
- Main Panel: Displays log entries for the selected file
- Log Entries: Click to expand and view full messages and stack traces
- Delete Button: Remove old log files (with confirmation)
Log Entry Features
Each log entry displays:
- Log Level: Color-coded badges (debug, info, warning, error, etc.)
- Timestamp: When the log entry was created
- Environment: Application environment (production, local, staging, etc.)
- Message: The log message (truncated with expand option)
- Stack Trace: Full error details and stack trace (when available)
Mobile Experience
The interface is fully responsive:
- Collapsible sidebar on mobile devices
- Touch-friendly interactions
- Optimized layout for smaller screens
- Swipe gestures and mobile navigation
๐จ Screenshots
Desktop View
The main interface showing log files in the sidebar and expanded log entries:
๐ง Advanced Usage
Custom Middleware
Create custom middleware for role-based access:
Register and use the middleware:
Integration with Laravel Gates
Use Laravel's authorization gates:
Environment-Specific Configuration
Configure different access rules per environment:
๐งช Log Format Support
The package supports both Laravel log formats simultaneously in the same file:
Classic Text Format
JSON Format (Monolog JsonFormatter)
To use the JSON formatter in your Laravel application, configure your config/logging.php:
Supported Log Levels
| Level | Color | Description |
|---|---|---|
| ๐ DEBUG | Gray | Detailed debug information |
| โน๏ธ INFO | Blue | General information messages |
| โน๏ธ NOTICE | Blue | Normal but significant events |
| โ ๏ธ WARNING | Yellow | Warning messages |
| โ ERROR | Red | Error conditions |
| ๐จ CRITICAL | Dark Red | Critical conditions |
| ๐จ ALERT | Dark Red | Action must be taken immediately |
| ๐ EMERGENCY | Purple | System is unusable |
๐ก๏ธ Security Considerations
Production Environment
For production use, implement strict access controls:
IP Restriction
Add IP-based restrictions:
Audit Logging
Log access to the log viewer:
๐ Troubleshooting
Common Issues
1. "No log files found"
- Ensure logs exist in
storage/logs/ - Check file permissions (Laravel must be able to read the directory)
- Verify the log files have
.logextension
2. "Access denied" or 403 errors
- Check authentication status
- Verify middleware configuration
- Ensure user has required permissions
3. Empty or garbled log entries
- Check log file format compatibility
- Ensure files are not corrupted
- Verify character encoding (UTF-8)
4. Performance issues with large log files
- Consider log rotation
- Archive old log files
- Use Laravel's log rotation features
Debug Mode
Enable debug logging for troubleshooting:
๐ Log Rotation & Maintenance
Automatic Cleanup
Set up automatic log cleanup:
File Size Management
Monitor and manage large log files:
๐ค Contributing
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Setup
๐ API Reference
Services
LogFileService
getLogFiles(): Collection- Get all available log fileslogFileExists(string $filename): bool- Check if log file existsgetLogFileContent(string $filename): string- Get log file contentdeleteLogFile(string $filename): bool- Delete a log file
LogParserService
parseLogFile(string $filename): Collection- Parse log file into entriesparseLogContent(string $content): Collection- Parse log content
LogEntry (Data Object)
$timestamp- Log entry timestamp$environment- Application environment$level- Log level (debug, info, warning, error, etc.)$message- Log message$extra- Additional data (stack traces, context)
Routes
| Method | URI | Action | Description |
|---|---|---|---|
| GET | /logs |
LogViewerController@index |
Display log viewer interface |
| DELETE | /logs/delete |
LogViewerController@delete |
Delete a log file |
๐ License
This package is open-sourced software licensed under the MIT License.
๐จโ๐ป Author
Mikail Faruq Ali
- Email: [email protected]
- GitHub: @mikailfaruqali
๐ Acknowledgments
- Laravel community for the amazing framework
- Bootstrap Icons for the beautiful icons
- All contributors who help improve this package
โญ If you find this package useful, please give it a star on GitHub! โญ