apextoolbox/symfony-logger

Apex Toolbox Symfony Bundle

Installs: 19

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/apextoolbox/symfony-logger

dev-main / 2.x-dev 2025-11-21 16:12 UTC

This package is auto-updated.

Last update: 2025-11-21 16:12:18 UTC


README

PHP Version Symfony

This is the official Symfony SDK for Apex Toolbox - Automatic logging, error tracking, and request monitoring for Symfony applications.

Getting Started

Install

composer require apextoolbox/symfony-logger

Configure

  1. Register the bundle in config/bundles.php (if not auto-registered):
return [
    // ...
    ApexToolbox\SymfonyLogger\ApexToolboxBundle::class => ['all' => true],
];
  1. Add your token to .env:
APEX_TOOLBOX_TOKEN=your_token_here
  1. Create config/packages/apex_toolbox.yaml:
apex_toolbox:
    enabled: true
    token: '%env(resolve:APEX_TOOLBOX_TOKEN)%'

    path_filters:
        include: ['*']           # Track all routes
        exclude: ['_profiler/*'] # Exclude Symfony profiler

Usage

That's it! All logs, exceptions, HTTP requests, and database queries are automatically tracked:

// Standard Monolog logging - automatically sent to ApexToolbox
$logger->info('User created', ['user_id' => 123]);
$logger->error('Payment failed', ['order_id' => 456]);
$logger->warning('Slow query detected', ['duration' => 2.5]);

// Uncaught exceptions are automatically captured
throw new Exception('Something went wrong');

// HTTP requests are automatically monitored
// GET /api/users - tracked with full request/response data

// Console commands are tracked
// php bin/console app:process-orders - all logs correlated with request_id

// Queue jobs are tracked
// All Messenger handler logs are captured and correlated

What's Tracked Automatically

  • All logs - Via Monolog integration with source file/line/class tracking
  • HTTP requests - Request/response data, headers, payload, performance metrics
  • Exceptions - Full stack traces with code context
  • Database queries - SQL queries with N+1 detection (Doctrine DBAL)
  • Console commands - All command execution logs
  • Queue jobs - Messenger handler execution logs
  • Correlation - All data linked via UUID v7 request_id
  • Security - Sensitive data (passwords, tokens, API keys) filtered by default

Configuration

The bundle is configured in config/packages/apex_toolbox.yaml:

apex_toolbox:
    enabled: true
    token: '%env(resolve:APEX_TOOLBOX_TOKEN)%'

    # Path filtering - which routes to track
    path_filters:
        include: ['*']            # Track all routes (or 'api/*' for API only)
        exclude: ['_profiler/*']  # Skip Symfony profiler

    # Request/response security filtering
    headers:
        exclude: ['authorization', 'cookie', 'x-api-key']
        include_sensitive: false

    body:
        exclude: ['password', 'password_confirmation', 'token', 'secret', 'api_key']
        mask: ['email', 'phone', 'ssn']
        max_size: 10240  # Maximum body size in bytes

    response:
        exclude: ['password', 'token', 'secret']
        mask: ['email', 'phone', 'ssn']

Key Features

Automatic Request Correlation

All logs, exceptions, and queries from the same request/command/job share a unique request_id (UUID v7):

  • HTTP requests get a request_id on kernel.request
  • Console commands get a request_id on console.command
  • Queue jobs get a request_id on message received
  • All related data is linked for easy debugging

Database Query Tracking

If Doctrine DBAL is installed, queries are automatically tracked:

  • SQL queries with bindings
  • Query duration
  • Duplicate query detection
  • N+1 query detection - automatic pattern-based detection
  • Source location (file, line)

Source Introspection

All logs include source information via Monolog's IntrospectionProcessor:

  • File path
  • Line number
  • Class name
  • Function name

Independent Data Transmission

Each type of data is sent independently but correlated:

  • Logs can be sent without HTTP requests
  • Exceptions tracked even outside HTTP context
  • Console/queue logs work standalone
  • Everything linked via request_id for correlation

Requirements

  • PHP 8.0 or higher
  • Symfony 5.4, 6.x, or 7.x
  • Monolog 2.x or 3.x (installed automatically)
  • Optional: Doctrine DBAL for query tracking

Resources

License

Licensed under the MIT License.