Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Shadow Logger Bundle Laravel Package

aubes/shadow-logger-bundle

Symfony bundle adding a Monolog processor to transform/anonymize sensitive log data for GDPR compliance. Supports IP anonymization, hashing, encryption, and field removal via configurable mappings for context/extra, with strict and debug modes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Monolog Integration: Seamlessly integrates with Laravel’s Monolog-based logging (via monolog/monolog package), requiring minimal architectural changes. Laravel’s logging system already supports processors, making this a drop-in solution for GDPR-compliant log anonymization.
  • Symfony Compatibility: While designed for Symfony, the bundle’s core functionality (Monolog processors) is framework-agnostic. Laravel’s Symfony components (e.g., symfony/dependency-injection) ensure compatibility without tight coupling.
  • Modular Design: Transformers (e.g., ip, hash, encrypt) are decoupled, allowing selective adoption (e.g., use ip for GDPR compliance without encrypt for performance).

Integration Feasibility

  • Low Friction: No database migrations or schema changes required. Configuration is YAML-based (shadow-logger.yaml), aligning with Laravel’s config/ structure.
  • Existing Stack Fit:
    • Logging: Works with Laravel’s default Monolog setup (e.g., single, daily, or syslog handlers).
    • Environment Variables: Leverages Laravel’s .env for secrets (e.g., SHADOW_LOGGER_ENCODER_SALT), reducing configuration drift.
    • Service Container: Compatible with Laravel’s DI container (e.g., custom encryptors/services can be registered via AppServiceProvider).
  • Handler/Channel Scoping: Supports granular application (e.g., restrict to single handler for production logs, exclude debug handler).

Technical Risk

Risk Area Severity Mitigation
Key Management High Requires secure .env storage and rotation. Use Laravel’s Vault or AWS KMS.
Performance Overhead Medium Encryption/hashing adds CPU cost. Benchmark with ab or Blackfire; cache keys.
Transformer Failures Low Configurable strict: true/false controls fallback behavior (null vs. original).
Nested Field Access Low Dot notation uses Symfony\Component\PropertyAccess, which may be slower.
Monolog Version Mismatch Low Bundle supports Monolog 2/3; Laravel 10+ uses Monolog 3 by default.
Custom Transformer Errors Medium Undocumented exceptions may crash log processing. Wrap in try-catch in config.

Key Questions

  1. Compliance Requirements:
    • Does your organization need reversible encryption (for GDPR right of access) or irreversible hashing (for pseudonymization)?
    • Are there specific fields (e.g., PII, payment data) that must be anonymized vs. optional?
  2. Performance Constraints:
    • What’s the expected log volume? Encryption adds ~10–50ms per log entry (benchmark with your data).
    • Can you scope transformers to non-critical handlers (e.g., exclude debug handler)?
  3. Key Rotation Strategy:
    • How will you rotate SHADOW_LOGGER_ENCODER_SALT or encryption keys without breaking historical logs?
    • Will you use the built-in DefaultEncryptor or a custom solution (e.g., AWS KMS)?
  4. Monitoring:
    • How will you detect transformer failures (e.g., malformed IP addresses breaking ip transformer)?
    • Should you enable debug: '%kernel.debug%' in production for critical issues?
  5. Testing:
    • Do you have a staging environment to validate log anonymization before production?
    • How will you verify that sensitive data is actually removed from logs (e.g., audit trails)?

Integration Approach

Stack Fit

  • Laravel-Specific Adaptations:
    • Replace Symfony’s Bundle with a Laravel ServiceProvider (if needed) to publish config and bind services.
    • Use Laravel’s config() helper to access shadow_logger settings (e.g., config('shadow_logger.mapping')).
    • Leverage Laravel’s .env for secrets (e.g., SHADOW_LOGGER_ENCRYPTOR_KEY).
  • Monolog Integration:
    • Laravel’s default Monolog setup (via Illuminate\Log\LogServiceProvider) is compatible. No additional packages required.
    • Example handler configuration in config/logging.php:
      'channels' => [
          'single' => [
              'processors' => [
                  Aubes\ShadowLoggerBundle\Processor\ShadowProcessor::class,
              ],
          ],
      ],
      
  • Alternative: Standalone Processor: If avoiding the bundle, manually register the ShadowProcessor in AppServiceProvider:
    use Aubes\ShadowLoggerBundle\Processor\ShadowProcessor;
    use Monolog\Logger;
    
    public function register()
    {
        $this->app->extend(Logger::class, function ($logger) {
            $logger->pushProcessor(new ShadowProcessor(
                config('shadow_logger.mapping'),
                config('shadow_logger.encoder'),
                config('shadow_logger.encryptor')
            ));
            return $logger;
        });
    }
    

Migration Path

  1. Assessment Phase (1–2 days):
    • Audit existing loggers (e.g., Log::channel(), Log::error() calls) to identify PII fields.
    • Decide on transformer strategy (e.g., hash for user IDs, ip for IPs, encrypt for emails).
  2. Configuration (1 day):
    • Publish the bundle config:
      php artisan vendor:publish --provider="Aubes\ShadowLoggerBundle\ShadowLoggerBundle"
      
    • Configure shadow-logger.yaml with your mapping (start with strict: false for testing).
  3. Testing (2–3 days):
    • Unit Tests: Mock Monolog processors to verify transformer outputs.
    • Integration Tests: Log test data with PII and validate anonymization (e.g., check logs for --obfuscated-- or hashed values).
    • Performance Tests: Measure impact on log throughput (e.g., Log::info() in a loop).
  4. Deployment (1 day):
    • Roll out to staging with debug: true to catch transformer errors.
    • Monitor log levels for warnings/errors (e.g., monolog.processor.error).
  5. Optimization (Ongoing):
    • Scope transformers to specific handlers/channels (e.g., exclude debug handler).
    • Adjust strict mode based on error rates.

Compatibility

Component Compatibility Notes
Laravel Version 8.0+ (Symfony 5.4+) or 9.0+ (Symfony 6+) Tested with Symfony 6/7/8; Laravel 10+ uses Monolog 3.
Monolog 2.x or 3.x Laravel 10+ uses Monolog 3 by default.
PHP 8.1+ Laravel 9+ requires PHP 8.1+.
Database None (log-only) No schema changes required.
Queue Workers Yes Loggers in queue jobs (e.g., Log::error() in HandleJob) are affected.
Third-Party Loggers Partial Custom Monolog handlers (e.g., Sentry, Papertrail) will process logs.

Sequencing

  1. Phase 1: Core Compliance
    • Implement ip, hash, and remove transformers for critical PII (e.g., user_ip, email, credit_card).
    • Validate logs in staging for anonymization.
  2. Phase 2: Advanced Use Cases
    • Add encrypt transformer for reversible anonymization (e.g., support GDPR right of access).
    • Implement custom transformers (e.g., truncate for tokens).
  3. Phase 3: Optimization
    • Profile log performance with tideways/xhprof-laravel and optimize transformer scoping.
    • Automate key rotation (e.g., use Laravel Forge or Envoyer for .env updates).

Operational Impact

Maintenance

  • Configuration Drift:
    • Risk: Manual edits to shadow-logger.yaml may diverge across environments.
    • Mitigation: Use Laravel’s config() caching or environment variables for dynamic values (e.g., salt).
  • Transformer Updates:
    • Risk: New transformer versions may introduce breaking changes (e.g., encryption algorithm updates).
    • Mitigation: Pin bundle version in composer.json until stability is confirmed.
  • Key Rotation:
    • Risk: Losing the encryption salt or key breaks historical log correlation.
    • Mitigation: Document rotation procedures and maintain a backup of old keys/salts for
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource