behnamhosseini/log-to-json
Convert Laravel log output to JSON. Choose between two logging modes via a simple config setting, and publish the package config to customize behavior. Install via Composer and integrate with your existing Laravel logging setup.
Formatter interface, requiring minimal changes to existing logging pipelines.| Risk | Mitigation |
|---|---|
| Log Volume Spikes | Test performance under high-throughput scenarios; consider async processing. |
| Schema Drift | Document JSON schema explicitly to avoid breaking consumers. |
| Tooling Incompatibility | Validate compatibility with log aggregators (e.g., Fluentd, Logstash). |
| Deprecation Risk | Monitor Laravel/Monolog updates for breaking changes (last release: 2021). |
context, extra)?SingleLineFormatter, LineFormatter) that need preservation?config/logging.php) and identify target channels for JSON conversion.level, message, context, timestamp).SingleLineFormatter with LogToJson\JsonFormatter in target channels.
'channels' => [
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.json'),
'level' => 'debug',
'formatter' => \LogToJson\JsonFormatter::class, // Add this line
],
],
jq or log aggregators.stream, syslog, and database handlers if they support formatters.context data).context contains non-serializable objects (e.g., closures).SingleLineFormatter to isolate issues.| Issue Type | Owner | Resolution Path |
|---|---|---|
| JSON Parsing Errors | DevOps/Observability | Validate schema, update log shippers. |
| Performance Bottlenecks | Backend Team | Optimize serialization or use async logging. |
| Laravel Upgrade Issues | TPM/Dev | Test compatibility; patch if needed. |
monolog process memory usage during spikes.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Log Shipper Rejects Malformed JSON | Data loss, alert fatigue | Implement pre-ship validation. |
| JSON Serialization Fails | Logs written in fallback format | Add retry logic for transient failures. |
| Schema Changes Break Consumers | Dashboard/API failures | Use backward-compatible field additions. |
| High Log Volume Overloads Storage | Storage costs, slow queries | Archive cold logs; implement log retention. |
LOGGING.md with:
message vs. structured_data).How can I help you explore Laravel packages today?