Download the PHP package gopimosali/global-logger without Composer
On this page you can find all versions of the php package gopimosali/global-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gopimosali/global-logger
More information about gopimosali/global-logger
Files in gopimosali/global-logger
Package global-logger
Short Description Universal Laravel logging with automatic request tracking, multi-provider support (AWS CloudWatch/X-Ray, Datadog, Oracle Cloud, Database, Files), and optional performance tracing
License MIT
Informations about the package global-logger
GlobalLogger for Laravel
A powerful, production-ready Laravel logging package that provides universal request tracking and multi-provider support with automatic correlation across AWS CloudWatch/X-Ray, Datadog, Oracle Cloud, Database, and file-based logs.
🎯 Key Features
- Automatic Request Correlation - Every log includes a unique
request_idfor complete request tracing - Multiple Providers - Send logs to AWS CloudWatch/X-Ray, Datadog, Oracle Cloud, Database, and files simultaneously
- Optional Performance Tracing - Track operation performance with automatic or manual traces
- Automatic Tracing - Auto-trace HTTP requests, database queries, queue jobs, emails, and cache operations
- PSR-3 Compliant - Standard logging interface compatible with all Laravel applications
- Zero Code Changes - Works as a drop-in replacement for Laravel's
Logfacade - Production Ready - Battle-tested with comprehensive error handling
📦 Installation
Publish Configuration
Publish Database Migration (if using Database provider)
🚀 Quick Start
1. Enable a Provider
Edit your .env file:
2. Use It (No Code Changes!)
3. See the Results
All your logs now automatically include request_id across all enabled providers:
🎓 Understanding request_id vs Traces
request_id (Automatic - You Don't Do Anything!)
The request_id is automatically generated once per request and included in every log. It allows you to correlate all logs from a single request.
You don't need to do anything - it just works!
Search all logs from one request:
- CloudWatch:
{ $.request_id = "550e8400..." } - Datadog:
@request_id:550e8400... - X-Ray:
annotation.request_id = "550e8400..."
Traces (Optional - For Performance Tracking)
Traces are optional and used to measure how long specific operations take. Use them when you want to see:
- Which operations are slow
- Performance bottlenecks
- Detailed timing breakdowns
Option 1: Automatic Tracing (Recommended)
Enable automatic tracing in .env:
Now all HTTP requests, database queries, queue jobs, and emails are automatically traced - no code changes needed!
Option 2: Manual Tracing (For Custom Operations)
Wrap important operations with manual traces:
See traces in:
- AWS X-Ray: Visual service map showing all traced operations
- Datadog APM: Flame graphs and performance metrics
- Logs: Search for
type:traceto see all performance data
📊 Complete Example: E-Commerce Checkout
Here's a complete example showing both automatic request_id correlation and optional performance tracing:
What You See in AWS X-Ray:
What You See in CloudWatch Logs:
Search all logs from this checkout:
Returns ALL logs and traces from start to finish!
🔧 Provider Configuration
AWS CloudWatch + X-Ray
Install AWS SDK:
Features:
- Logs sent to CloudWatch Logs
- Traces visualized in X-Ray service map
request_idconverted to X-Ray trace ID format- Original
request_idpreserved in annotations
Datadog
Install Datadog PHP:
Features:
- Logs sent to Datadog Logs
- Traces visualized in Datadog APM
request_idconverted to Datadog trace ID format- Original
request_idpreserved in tags
Oracle Cloud Logging
Complete integration with Oracle Cloud Infrastructure (OCI) Logging service with automatic request signing.
Quick Setup
Detailed Setup Steps
1. Create a Log in OCI Console:
2. Generate OCI API Key:
3. Add API Key to OCI User:
4. Create IAM Policy:
5. Set File Permissions (Important!):
Regional Endpoints
Choose the correct endpoint for your OCI region:
Testing Oracle Cloud Logging
Features:
- ✅ Native OCI Logging Ingestion API (20200831)
- ✅ Automatic request signing with RSA-SHA256
- ✅ Proper x-content-sha256 header generation
- ✅ Full request context preserved (request_id, timestamp, environment)
- ✅ JSON-formatted log entries
- ✅ Automatic error handling with detailed error messages
- ✅ Compatible with all OCI regions
Troubleshooting:
Common issues and solutions:
Database
Features:
- Store logs in your database
- Query logs with Eloquent
- Index on
request_idfor fast searches
Publish and run migration:
Custom File Logging
Features:
- Rotating file handler (14 days by default)
- JSON-formatted logs
- Local development friendly
- Optional stdout support for Docker/Kubernetes
Enable Stdout Output (Docker/Kubernetes)
For containerized environments, you can output logs to stdout with full GlobalLogger context:
Or configure per environment in .env:
Configuration in config/globallogger.php:
What you get in stdout:
All logs are output as JSON with full context:
Benefits:
- ✅ Docker logs:
docker logs -f container-nameshows structured JSON - ✅ Kubernetes: Logs collected by K8s with full context
- ✅ Log aggregation: Easy parsing by CloudWatch, Datadog, ELK, etc.
- ✅ Same rich context: request_id, timestamp, environment in every log
- ✅ File + stdout: Logs written to both file and stdout simultaneously
Test stdout logging:
🎯 When to Use What?
Use request_id (Always Automatic!)
✅ You don't need to do anything - it's automatic!
Perfect for:
- Correlating all logs from one request
- Debugging user issues
- Following a request through microservices
- Understanding what happened during an error
Search examples:
Use Automatic Tracing (Recommended!)
✅ Just enable it - no code changes needed!
Perfect for:
- Automatically tracking all HTTP, database, queue, and mail operations
- Reducing boilerplate code
- Ensuring nothing is missed
- Quick performance insights
What gets traced:
- HTTP requests (Laravel
Http::facade) - Database queries (Eloquent and Query Builder)
- Queue jobs (all dispatched jobs)
- Email sending (Laravel
Mail::facade) - Cache operations (optional)
Use Manual Tracing (When Needed)
✅ Wrap specific operations when automatic tracing isn't enough
Perfect for:
- Custom business logic
- Third-party SDK calls
- File operations
- Complex algorithms
- External API calls not using Laravel's
Http::
Example:
📚 Advanced Usage
Passing request_id to External Services
Adding Custom Context
Converting request_id Formats
🔍 Searching and Querying
AWS CloudWatch Logs Insights
AWS X-Ray
Datadog
Database (Eloquent)
🔇 Noise Filtering
GlobalLogger provides configurable filtering to suppress noisy framework-internal events from polluting your logs.
Cache Key Filtering
Laravel's queue workers poll cache keys like illuminate:queue:restart every few seconds per worker. With multiple Horizon workers, this generates thousands of cache miss log entries daily — all expected, harmless, and unactionable.
Configure ignored_keys in config/globallogger.php to silence them:
Supports exact matches and wildcard patterns using * (powered by Str::is()).
Database Query Filtering
Suppress noisy or irrelevant queries from being logged, even if they exceed the slow query threshold:
Both ignored_queries (wildcard SQL patterns) and ignored_tables (table name matching) are case-insensitive.
🛠️ Troubleshooting
Logs Not Appearing
Check provider is enabled:
Check file permissions:
Check AWS credentials:
request_id Not Showing
Ensure middleware is registered:
Middleware should show Gopimosali\GlobalLogger\Middleware\LogContextMiddleware.
Traces Not Appearing in X-Ray
Check X-Ray daemon is running:
Check X-Ray is enabled:
📖 Additional Documentation
- TRACING_GUIDE.md - Detailed guide on when and how to use traces
- REQUEST_ID_FLOW.md - How request_id flows through systems
- AUTO_TRACING_GUIDE.md - Complete automatic tracing documentation
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
📄 License
The MIT License (MIT). Please see LICENSE for more information.
🙏 Credits
Created by Gopi Mosali
Special thanks to the Laravel community for inspiration and feedback.
⭐ Show Your Support
If this package helps you, please star it on GitHub! ⭐
All versions of global-logger with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/log Version ^10.0|^11.0|^12.0
ramsey/uuid Version ^4.7