Download the PHP package hddev/laravel-request-logger without Composer

On this page you can find all versions of the php package hddev/laravel-request-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-request-logger

Laravel Request Logger

Structured HTTP request logging for Laravel 12+. Logs the full request lifecycle (request.start, request.end, request.exception) as structured context, correlates everything with a request ID propagated through the Laravel Context and returned in a response header, and redacts sensitive data recursively.

Built for platforms where logs are queried, not read: every entry carries a machine-parsable event, a request_id, HTTP metadata, user identity and performance figures. On Azure Container Apps + Log Analytics, this makes any request traceable end to end with a single KQL query.

Why not spatie/laravel-http-logger?

Spatie's package logs the incoming request only. This package logs the lifecycle: start and end as two correlated events with status code, duration, memory peak, resolved route and authenticated user, plus a dedicated exception event. It borrows Spatie's best ideas: pluggable LogProfile / LogWriter classes and header sanitization.

Installation

Publish the config file if you need to customize beyond env variables:

Usage

Register the middleware in bootstrap/app.php. Register it before auth middlewares so the whole request is timed; user identity is still captured on request.end because auth has run by then.

Or on a group only:

What gets logged

Note on exceptions: with Laravel's exception handler active, throwables are rendered into a 500 response inside the routing pipeline, so they surface as a request.end error event (the handler's own report shares the same request_id through the Context). The request.exception event is a safety net for throwables that escape the handler (handler unbound, rethrow, some Octane edge cases).

Every response also receives an X-Request-ID header, and request_id is added to the Laravel Context, so it appears on every log line written during the request and is propagated to queued jobs.

Configuration

Everything ships with sensible defaults and is driven by env variables:

Variable Default Description
REQUEST_LOGGER_ENABLED true Master switch
REQUEST_LOGGER_CHANNEL null Dedicated log channel (falls back to default)
REQUEST_LOGGER_LOG_BODY false Log the sanitized request body on start
REQUEST_LOGGER_LOG_HEADERS false Log sanitized headers on start
REQUEST_LOGGER_REQUEST_ID_HEADER X-Request-ID Response header carrying the request ID
REQUEST_LOGGER_FAIL_SILENTLY true Never break a request on logging failure

Exclusions (paths with wildcards, route names, HTTP methods), sensitive keys/headers and the redaction placeholder are configured in config/request-logger.php.

Dedicated channel (recommended in production)

Keep request logs separate, queryable, and cheap to purge. Example config/logging.php channel writing JSON to stderr (Docker/Container Apps friendly):

Then set REQUEST_LOGGER_CHANNEL=requests.

Running Octane with the FrankenPHP server? Use OctaneSafeJsonFormatter instead of JsonFormatter. See Octane.

Extending

Three contracts, all swappable from config:

DefaultLogWriter exposes protected extension points (logger(), logLevel(), title(), performance()) so partial overrides stay small.

Full architecture walkthrough and extension use cases: docs/extending.md.

Octane

The middleware resolves its collaborators per request and stores the request ID in the Laravel Context, which Octane resets between requests. No state leaks across workers. Two consecutive requests always get distinct request IDs (covered by tests).

FrankenPHP: use OctaneSafeJsonFormatter on stderr

With the FrankenPHP server, Octane reads the worker's stderr and parses every line as a Caddy log entry. A line that decodes to JSON but has no msg key is replaced by ERROR unknown error. before it ever reaches the container log collector.

Monolog's JsonFormatter writes message, not msg. So the recommended stderr channel above silently loses every request log: the middleware runs, the X-Request-ID header is returned, but the structured lines never make it out. Nothing throws, and fail_silently has no effect, because the write itself succeeds.

Point the channel at OctaneSafeJsonFormatter, which wraps each record in the envelope Octane forwards verbatim:

The emitted line stays a single JSON object per record, with the original payload nested under msg:

Log collectors that index raw stderr lines still see valid JSON. To query the inner payload, parse the msg string as JSON (for example parse_json(msg) in KQL).

You only need this when writing to stderr under FrankenPHP. File channels, stdout-based drivers and the Swoole/RoadRunner servers are unaffected, and JsonFormatter remains the right choice there.

Testing

Changelog

See CHANGELOG.

License

The MIT License (MIT). See LICENSE.


All versions of laravel-request-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.0
illuminate/http Version ^12.0
illuminate/log Version ^12.0
illuminate/routing Version ^12.0
illuminate/support Version ^12.0
monolog/monolog Version ^3.0
psr/log Version ^3.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hddev/laravel-request-logger contains the following files

Loading the files please wait ...