Download the PHP package gilbitron/canonical-context-logging-laravel without Composer

On this page you can find all versions of the php package gilbitron/canonical-context-logging-laravel. 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 canonical-context-logging-laravel

Canonical Context Logging - Laravel Package

Laravel integration for Canonical Context Logging - structured JSON logs with one wide event per request.

Overview

This package integrates the Canonical Context Logging PHP SDK with Laravel, providing:

Requirements

Installation

The service provider will be auto-discovered by Laravel.

Quick Start

1. Publish Configuration (Optional)

This creates config/canonical-context-logging.php with all available options.

2. Configure Environment Variables

Add to your .env:

3. That's It!

The middleware is automatically registered and will start logging requests. Each request will emit one structured JSON log entry with all context.

Usage

Automatic Logging

The middleware automatically captures:

Adding Custom Context

Use the Facade:

Or use helper functions:

Accessing Context Directly

Integration with Exception Handler

The middleware automatically captures exceptions, but you can also manually set errors in your exception handler:

Configuration

Exporter Types

Console Exporter (Development)

Outputs logs to stdout/stderr:

File Exporter

Writes logs to a file in JSONL format:

OTLP Exporter (Production)

Sends logs to an OpenTelemetry collector:

Or use standard OpenTelemetry environment variables:

Logger Settings

Tail-Sampling Rules:

Service Configuration

Middleware Configuration

Log Output Format

The structured log output follows this schema:

W3C Trace Context Support

The middleware automatically extracts trace and span IDs from the traceparent header if present:

This enables distributed tracing across services.

Disabling Middleware

To disable automatic request logging:

Or set environment variable:

You can still use the Facade and helpers to manually log events.

Manual Logging (Without Middleware)

If you disable the middleware, you can manually start and end contexts:

Testing

The package includes tests. Run them with:

Best Practices

  1. One log per request - The middleware handles this automatically
  2. Add business context - Use the Facade to add user, org, plan, feature flags, etc.
  3. Structured data only - No free-text messages, use consistent keys
  4. Tail-sample - Configure sampling to reduce volume while keeping errors and slow requests
  5. Error handling - Exceptions are automatically captured, but you can add additional context
  6. W3C Trace Context - Include traceparent headers in upstream requests for distributed tracing

License

MIT


All versions of canonical-context-logging-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/contracts Version ^10.0|^11.0|^12.0
gilbitron/canonical-context-logging Version ^0.2.1
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 gilbitron/canonical-context-logging-laravel contains the following files

Loading the files please wait ...