Search by

newgeode / everylogs

newgeode

Zero-config global middleware to log every HTTP request activity in Laravel.

Package info

github.com/newgeode/everylogs

pkg:composer/newgeode/everylogs

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.2.0 2026-12-03 19:09 UTC

This package is auto-updated.

Last update: 2026-12-03 19:10:00 UTC


README

EveryLogs is a Laravel middleware package that records HTTP request activity in a configurable database table. It can capture request IDs, authenticated-user identifiers, IP addresses, user-agent-derived client/device details, route information, response status, request duration, memory usage, and optional request/response payloads and IP geolocation.

Privacy note: Request logs can contain personal data and secrets. Keep payload logging disabled unless you have reviewed the data you collect, configured redaction, restricted access to the log table, and established an appropriate retention policy.

Requirements

  • PHP ^8.2
  • Laravel / Illuminate Support, HTTP, and Database components ^10.0, ^11.0, ^12.0, or ^13.0 (the selected Laravel version's own PHP requirements also apply).

Installation

composer require newgeode/everylogs
php artisan migrate

Laravel package discovery registers NewGeode\EveryLogs\EveryLogsServiceProvider, which loads the migration, merges the package configuration, and registers the everylogs middleware alias.

Enable the middleware

The package is disabled by default. Enable it in the application's environment:

EVL_ENABLED=true

To log all requests, append the middleware to the global middleware stack.

Laravel 11 and later — add this inside the existing withMiddleware callback in bootstrap/app.php:

use NewGeode\EveryLogs\Http\Middleware\EveryLogs;

->withMiddleware(function ($middleware) {
    $middleware->append(EveryLogs::class);
})

If your application already has a withMiddleware callback, add the append call to it rather than creating a second callback.

Laravel 10 — add the middleware class to the global $middleware array in app/Http/Kernel.php:

protected $middleware = [
    // ...
    \NewGeode\EveryLogs\Http\Middleware\EveryLogs::class,
];

Alternatively, apply the registered alias to selected routes:

Route::middleware('everylogs')->group(function () {
    // Routes to log
});

Publish configuration

php artisan vendor:publish --tag=everylogs-publish-config

This publishes config/everylogs.php. If you change table_name, do so before running the package migration. If the migration has already run, create a new application migration to rename or alter the existing table; changing the original package migration will not update an already-migrated database.

After changing environment values when configuration is cached, rebuild the configuration cache:

php artisan config:clear
# or, for deployment:
php artisan config:cache

Configuration

The following keys are defined in config/everylogs.php.

Configuration key Environment variable Default Purpose
everylogs.enabled EVL_ENABLED false Enables logging.
everylogs.table_name — ng_everylogs Database table used by the model and migration.
everylogs.ignore_paths EVL_IGNORE_PATHS up, _debugbar*, telescope*, horizon* Request paths excluded from log storage. Supports Laravel request path patterns.
everylogs.log_request_id EVL_LOG_REQUEST_ID false Generates/accepts a UUID request ID and returns it in X-Request-ID.
everylogs.log_request_payload EVL_LOG_REQUEST false Stores filtered request input for methods other than GET and HEAD.
everylogs.log_response_payload EVL_LOG_RESPONSE false Stores filtered JSON object/array response bodies.
everylogs.hidden_fields EVL_HIDDEN_FIELDS See config file Case-insensitive field names masked in query parameters and logged payload arrays.
everylogs.ipinfo.enabled EVL_IPINFO false Enables IPinfo lookup (see caveat below).
everylogs.ipinfo.plan EVL_IPINFO_PLAN lite IPinfo plan: lite, core, plus, max, or custom.
everylogs.ipinfo.token EVL_IPINFO_TOKEN empty IPinfo API token.
everylogs.ipinfo.connect_timeout EVL_IPINFO_CONNECT_TIMEOUT 2 seconds Connection timeout.
everylogs.ipinfo.timeout EVL_IPINFO_TIMEOUT 5 seconds Request timeout.
everylogs.ipinfo.store_in_cache EVL_IPINFO_STORE_IN_CACHE true Caches successful IP lookups.
everylogs.ipinfo.cache_config.default EVL_IPINFO_CACHE_DRIVER everylogs_ipinfo Cache store name.

The IPinfo settings are nested under ipinfo (not ip_info). The current implementation calls the IPinfo lookup from the middleware even when IPinfo is disabled; see the known issues in the accompanying security review before enabling this package in production.

Example environment configuration

EVL_ENABLED=true
EVL_LOG_REQUEST_ID=true

# Keep payload collection off unless required and reviewed.
EVL_LOG_REQUEST=false
EVL_LOG_RESPONSE=false

# Optional IPinfo integration. Review the implementation caveat above first.
EVL_IPINFO=false
EVL_IPINFO_PLAN=lite
EVL_IPINFO_TOKEN=

Do not commit real API tokens or credentials. Supply secrets through your deployment environment or secret manager.

Request IDs

When EVL_LOG_REQUEST_ID=true, EveryLogs checks the incoming X-Request-ID header. A UUID value is reused; otherwise, a UUID is generated. The ID is attached to the request attributes and returned in the response header. The request ID is stored with the log entry.

Request and response payload logging

Payload logging is disabled by default.

  • Request input is collected for methods other than GET and HEAD.
  • Response payload logging is limited to response bodies that decode as JSON arrays or objects.
  • The configured hidden_fields keys are masked recursively in arrays, using case-insensitive key matching.

For example:

EVL_LOG_REQUEST=true
EVL_LOG_RESPONSE=true
EVL_HIDDEN_FIELDS=password,password_confirmation,token,access_token,refresh_token,authorization,api_key,client_secret

This is a denylist-based filter, not a guarantee that all secrets are removed. Add application-specific secret field names and test redaction against real request/response shapes before enabling payload logging. Non-array objects, secrets embedded in strings, headers, cookies, uploaded files, and sensitive values in URL path segments are not comprehensively redacted by the current implementation. Prefer leaving payload logging disabled for authentication, payment, personal-data, and other sensitive endpoints; use ignore_paths where appropriate.

IP geolocation

The package includes an IPinfo client. Obtain credentials from IPinfo and configure the environment variables above. IPinfo lookup requires outbound network access. Successful results may be cached using the configured Laravel cache store.

Current implementation warning: the middleware invokes the lookup for each logged request regardless of EVL_IPINFO. The IPinfo client returns a disabled status when the feature is off, and the middleware currently logs that as an error. This should be corrected before production use (see SECURITY_REVIEW.md).

Applications behind a reverse proxy

EveryLogs obtains the client address through Laravel's $request->ip(). Configure Laravel's trusted-proxy handling correctly when deploying behind a load balancer, reverse proxy, or CDN. Trust only known proxy addresses/CIDR ranges. Incorrectly trusting arbitrary forwarded headers can allow clients to spoof their apparent IP address.

Database model and querying

use NewGeode\EveryLogs\Models\EveryLogs;

$recentRequests = EveryLogs::query()
    ->latest()
    ->limit(100)
    ->get();

The model casts geolocation, request_payload, and response_payload to arrays.

The migration stores these fields:

  • Identity: request_id, causer_type, causer_id
  • Client: ip_address, os, device, client_type, client_name, client_version, useragent
  • Location: location, geolocation
  • Request: method, event, url, path, route, locale, time_zone
  • Response/performance: status, request_payload, response_payload, duration_ms, memory_mb, created_at

Operational and privacy recommendations

  1. Keep payload logging off unless there is a documented need.
  2. Restrict database and log-file access to authorized operators.
  3. Establish a retention/deletion policy for request logs.
  4. Exclude sensitive routes and avoid putting secrets in URL query strings or path segments.
  5. Configure trusted proxies before relying on logged client IP addresses.
  6. Monitor log volume and database growth; this middleware can create one database row for each request it processes.
  7. Review SECURITY_REVIEW.md and address its findings before production deployment.

Support

Report issues in the source repository where you obtained the package. Include PHP and Laravel versions and a minimal reproduction. Do not include real user data, API tokens, passwords, session identifiers, or other secrets.