-
Notifications
You must be signed in to change notification settings - Fork 2
ElkLogger
Viames Marino edited this page Feb 23, 2026
·
1 revision
Pair\Services\ElkLogger sends structured logs to Elasticsearch/ELK.
Use it for centralized observability, production diagnostics, and log analytics in Kibana.
__construct(string $elkUrl, ?string $elkUser = null, ?string $elkPassword = null)log(string $message, string $level = 'info', array $context = []): void
$elk = new \Pair\Services\ElkLogger(
getenv('ELK_URL'),
getenv('ELK_USER') ?: null,
getenv('ELK_PASSWORD') ?: null
);
$elk->log('Order exported', 'info', ['orderId' => 2241]);try {
(new ImportService())->run();
} catch (\Throwable $e) {
$elk->log('Import failed', 'error', [
'exception' => $e->getMessage(),
'traceId' => $traceId
]);
throw $e;
}- Sending unstructured strings limits queryability in ELK.
- Credentials/timeouts should be configured per environment.