fluent/logger package is a lightweight, direct PHP-to-Fluentd logging solution, ideal for applications requiring structured logging with minimal overhead. It fits well in architectures where:
create_function, weak typing).AppServiceProvider or a dedicated logger service).Monolog; high if mixing with other loggers (e.g., stack handlers).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Deprecated Code | High | Replace FluentLogger with a wrapper or fork to modernize (e.g., add PSR-3 support). |
| No Buffering | High | Deploy a local Fluentd proxy (as recommended) to handle retries/buffering. |
| Thread Safety | Medium | Ensure single-process usage or use a proxy. |
| Lack of Maintenance | Medium | Fork or extend for critical features (e.g., TLS, async support). |
| Performance | Low | Benchmark against Monolog + Fluentd handler. |
post("tag", ["key" => "value"]) sufficient?monolog/handler-fluentd (PSR-3 compliant, but slower).symfony/var-dumper + custom Fluentd client.Log::channel() with a Fluentd handler.Log::stack(), context binding).config/logging.php support).Laravel 10.x
├── fluent/logger (v1.0.1, forked for PHP 8.x)
├── fluentd-proxy (Docker sidecar, v1.15+)
└── central Fluentd (v1.16+ with `out_elasticsearch`/`out_s3`)
Log::debug()) with FluentLogger in a non-critical service.fluent/fluentd:latest).Log::channel().reactphp or pthreads).FluentLogger with Laravel’s LogManager:
// app/Providers/AppServiceProvider.php
public function register()
{
Log::extend('fluent', function ($app) {
return new class {
public function __invoke(array $config)
{
$logger = new Fluent\Logger\FluentLogger(
$config['host'] ?? 'localhost',
$config['port'] ?? 24224
);
return new LaravelFluentHandler($logger);
}
};
});
}
Sidecar or Docker network_mode: host).in_forward to buffer logs locally before forwarding to central Fluentd.| Component | Compatibility Notes |
|---|---|
| PHP 8.x | ❌ Not natively supported. Requires fork or polyfills (e.g., ext-json for json_encode). |
| Laravel 8+ | ✅ Works, but lacks Log::stack() or context binding. |
| Fluentd 1.x | ✅ Tested with v0.9.20+. Modern v1.x may need config tweaks (e.g., in_forward buffer). |
| Docker/K8s | ✅ Proxy pattern works well in containers. |
| Windows | ❌ Unlikely to work (Fluentd is Unix-focused). |
Log:: calls in critical paths (e.g., API controllers, jobs).out_exec (e.g., tail -f /var/log/fluent.log).logger->ping()).Monolog + FluentdHandler for PSR-3 compliance.prometheus exporter for log latency).in_forward supports it, but PHP client does not).<buffer> settings in fluent.conf (e.g., flush_interval, chunk_limit).in_forward buffer paths (e.g., /var/log/fluent-buffer).How can I help you explore Laravel packages today?