Download the PHP package central-logs/laravel without Composer
On this page you can find all versions of the php package central-logs/laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download central-logs/laravel
More information about central-logs/laravel
Files in central-logs/laravel
Package laravel
Short Description Laravel package for sending logs to Central Logs system with sync, async, and batch processing modes. Achieve 251x faster logging performance.
License MIT
Homepage https://github.com/pandeptwidyaop/central-logs-laravel
Informations about the package laravel
Central Logs Laravel
A powerful and flexible Laravel package for sending logs to Central Logs system with support for synchronous, asynchronous, and batch processing modes. Achieve up to 251x faster logging performance with intelligent batch aggregation.
Features
- ✅ Multiple Log Levels - Support for all 8 Monolog levels (DEBUG → EMERGENCY)
- ✅ Three Operation Modes - Sync, Async (Queue), and Batch aggregation
- ✅ Blazing Fast - Batch mode is 251x faster than sync (0.68ms vs 170ms)
- ✅ Exception Handling - Automatic exception serialization with stack traces
- ✅ Context Enrichment - Automatic capture of user, request, session, and environment data
- ✅ Queue Integration - Seamless integration with Laravel Queue (Redis, Database, etc.)
- ✅ Auto-Flush - Multiple flush triggers (size, timeout, shutdown, memory)
- ✅ Retry Logic - Exponential backoff with configurable attempts (default: 3)
- ✅ Fallback Mechanism - Local logging when API is unavailable
- ✅ Zero Data Loss - Shutdown hooks ensure all logs are sent
- ✅ Production Ready - 100% test coverage, error handling, graceful degradation
Version Compatibility
| Package Version | Laravel | PHP | Monolog |
|---|---|---|---|
| 1.3+ | 9.x, 10.x, 11.x, 12.x | ^8.0 | ^2.0|^3.0 |
| 1.0-1.2 | 10.x, 11.x, 12.x | ^8.1 | ^3.0 |
Requirements
- PHP 8.0 or higher
- Laravel 9.x, 10.x, 11.x, or 12.x
- Guzzle HTTP Client 7.8+
- Central Logs instance (running at accessible URL)
Performance Benchmarks
Real-world performance testing with Central Logs API:
| Mode | Speed | Blocking | Queued | Speedup | Best For |
|---|---|---|---|---|---|
| SYNC | 170.83ms | Yes | No | 1x | Critical logs |
| ASYNC | 57.71ms | No | Yes | 3x | High-throughput |
| BATCH | 0.68ms | No | On flush | 251x | Optimal performance |
Batch mode processes logs 251x faster than sync mode!
Installation
Step 1: Install via Composer
Step 2: Publish Configuration
This will create a config/central-logs.php file in your Laravel application.
Important: The package will work in "null mode" (no logs sent) until you configure the API credentials in Step 3.
Step 3: Configure Environment
Add the following to your .env file:
Step 4: Add Middleware (Recommended for Batch Mode)
Add the flush middleware to app/Http/Kernel.php to ensure logs are sent at the end of each request:
Why? In batch mode, logs are collected and sent in batches. Without this middleware, logs may wait until batch size (default: 50) or timeout (default: 5s) is reached. The middleware ensures logs are flushed after each request.
Step 5: Update Logging Configuration
Add the Central Logs channel to your config/logging.php:
Step 6: Test Connection
Quick Start
Once configured, you can use Laravel's logging as usual:
Configuration
Logging Modes
Synchronous Mode
Logs are sent immediately (blocks the request):
Pros: Logs are sent immediately Cons: Adds latency to requests
Asynchronous Mode (Recommended)
Logs are queued and sent via Laravel Queue:
Pros: Non-blocking, fast Cons: Requires queue worker to be running
Batch Processing
Enable batch processing to reduce API calls:
How it works:
- Logs are collected in memory
- Flushed when batch size is reached OR timeout elapsed
- Automatically flushed on application shutdown
Configuration Reference
All available configuration options in config/central-logs.php:
Advanced Usage
Custom Metadata
Add custom metadata to all logs:
Using Specific Channel
Log only to Central Logs:
Conditional Logging
Log to Central Logs only in production:
Exception Handling
The package automatically extracts exception details:
Queue Configuration
For async mode, you need a queue worker running:
Using Redis (Recommended)
Using Database
Start Queue Worker
Supervisor Configuration
Create /etc/supervisor/conf.d/central-logs-worker.conf:
Troubleshooting
Connection Test Fails
Check:
- Central Logs is running and accessible
- API key is correct
- Firewall/network settings allow connection
- URL is correct (include http:// or https://)
Logs Not Appearing
In Async Mode:
- Check queue worker is running:
ps aux | grep queue:work - Check queue for failed jobs:
php artisan queue:failed - Check Laravel logs:
tail -f storage/logs/laravel.log
In Batch Mode (Most Common Issue):
Problem: Logs not sent immediately, waiting until batch size or timeout reached
Solutions:
-
Add Flush Middleware (Recommended):
-
Lower Batch Settings for Development:
-
Disable Batching for Testing:
- Manual Flush in Tinker:
Performance Issues
Sync mode is slow:
- Switch to async mode for better performance
- Enable batch mode to reduce API calls
Queue backing up:
- Increase number of queue workers
- Check Central Logs API response time
- Reduce batch timeout for faster processing
Development
Setup Development Environment
Run Tests
Code Quality
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see LICENSE for more information.
Credits
- Pande
- All Contributors
Support
- Documentation
- Issue Tracker
All versions of laravel with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/contracts Version ^9.0|^10.0|^11.0|^12.0
illuminate/queue Version ^9.0|^10.0|^11.0|^12.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0
monolog/monolog Version ^2.0|^3.0
guzzlehttp/guzzle Version ^7.8