iqbalatma/laravel-log-center-channel

Laravel log channel that ships logs to a centralized log management system via M2M API

Maintainers

Package info

github.com/iqbalatma/laravel-log-center-channel

pkg:composer/iqbalatma/laravel-log-center-channel

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-07-15 18:36 UTC

This package is auto-updated.

Last update: 2026-07-16 03:36:08 UTC


README

A custom Laravel/Monolog log channel that ships log records to a centralized log management system over its M2M API.

How it works

  1. A global middleware (AssignRequestId) generates a UUID request_id per HTTP request and shares it as log context.
  2. The log_center channel formats each record into a structured payload (capturing the authenticated actor, IP, endpoint, method and request_id synchronously, while the request is still alive).
  3. The payload is dispatched to the queue (SendLogToCenterJob) and POSTed to {base_url}/api/m2m/logs with X-Client-Id / X-Client-Secret headers.
  4. Any failure is written to the configured fallback_channel instead of recursing.

Install (local path package)

composer.json:

"repositories": [
    { "type": "path", "url": "packages/iqbalatma/laravel-log-center-channel" }
]
composer require iqbalatma/laravel-log-center-channel:@dev
php artisan vendor:publish --tag=log-center-config

Configure

Add the channel in config/logging.php:

'log_center' => [
    'driver' => 'custom',
    'via' => \Iqbalatma\LaravelLogCenterChannel\Logger::class,
    'level' => \Psr\Log\LogLevel::ERROR,
],

Enable it, e.g. LOG_STACK=single,log_center in .env.

Environment

LOG_CENTER_BASE_URL=https://logs.example.com
LOG_CENTER_CLIENT_ID=your-client-id
LOG_CENTER_CLIENT_SECRET=your-client-secret
LOG_CENTER_APP_NAME=ng-hris
LOG_CENTER_NODE_ID=            # defaults to hostname
LOG_CENTER_ENVIRONMENT=       # defaults to APP_ENV (config('app.env'))
LOG_CENTER_TIMEOUT=5
LOG_CENTER_TRIES=3
LOG_CENTER_QUEUE_CONNECTION=redis
LOG_CENTER_QUEUE=default
LOG_CENTER_FALLBACK_CHANNEL=single

Payload

client_id, id, created_at, updated_at are set by the log center itself. The channel sends:

Field Source
message log message
level lowercased Monolog level
trace context.exception trace, if present
actor_id auth()->id() or guest
actor_email authenticated user email (nullable)
app_name LOG_CENTER_APP_NAME
node_id LOG_CENTER_NODE_ID / hostname
environment LOG_CENTER_ENVIRONMENT / config('app.env')
ip_address client IP (null in console)
endpoint request URI (null in console)
http_method request method (null in console)
request_id per-request UUID
logged_at record timestamp (ISO-8601)