Weave Code
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

Monolog Autowire Bundle Laravel Package

adrenalinkin/monolog-autowire-bundle

Symfony bundle that enables autowiring of Monolog channel loggers via generated decorator classes, plus a LoggerCollection fallback mechanism. Works even without MonologBundle: missing channels fall back to the default PSR-3 logger or NullLogger.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Developer Productivity & Maintainability: Enables seamless autowiring of Monolog loggers, reducing boilerplate and manual service configuration in Symfony/Laravel applications. Aligns with the goal of reducing technical debt by leveraging dependency injection (DI) best practices.
  • Consistent Logging Architecture: Facilitates a standardized way to access loggers across channels (e.g., app, security, audit), improving code consistency and reducing context-switching for developers.
  • Roadmap for Observability: Supports future initiatives to enhance logging granularity (e.g., per-module logging, structured logging) without disrupting existing DI patterns.
  • Build vs. Buy: Justifies a "build" decision for custom logging needs over third-party solutions (e.g., ELK stacks) by simplifying logger management within the existing framework.
  • Use Cases:
    • Microservices or modular monoliths where per-service logging is critical.
    • Applications requiring dynamic logger fallback (e.g., fallback to a NullLogger or default channel).
    • Teams adopting Symfony/Laravel’s autowiring but needing fine-grained control over Monolog channels.

When to Consider This Package

  • Adopt When:

    • Your project uses Symfony/Laravel with Monolog and relies on autowiring for DI.
    • You need type-safe logger injection (e.g., private LoggerInterface $logger in services) without manual YAML/XML configuration.
    • Your team prioritizes reducing coupling between logging setup and service definitions.
    • You require fallback logger behavior (e.g., gracefully handle missing channels).
    • You’re migrating from manual logger registration to autowiring or adopting autowiring for new features.
  • Look Elsewhere If:

    • Your project doesn’t use Symfony/Laravel or Monolog (e.g., native PHP, Lumen, or other frameworks).
    • You need advanced logging features (e.g., real-time dashboards, alerting) beyond channel routing—consider integrating with tools like Sentry, ELK, or Humio.
    • Your team prefers explicit logger configuration (e.g., for auditability or debugging).
    • The package’s maturity is a concern (low stars/downloads; evaluate alternatives like symfony/monolog-bundle extensions or custom solutions).
    • You’re using Laravel’s built-in logging without Monolog (this package is Symfony-focused).

How to Pitch It (Stakeholders)

For Executives/Business Leaders:

"This package streamlines how our developers access and manage application logs by automating the setup of Monolog channels through Symfony/Laravel’s autowiring system. It reduces manual configuration errors, improves code maintainability, and aligns with our tech stack’s best practices. For example, instead of hardcoding loggers in services, developers can simply declare them as dependencies (e.g., private LoggerInterface $auditLogger), making the codebase more scalable and easier to debug. This is a low-risk, high-reward change that supports our observability goals without requiring new tooling."

For Engineering/Tech Leads:

*"The Monolog Autowire Bundle solves a pain point in our logging architecture: manual service definitions for Monolog channels. By enabling autowiring, we eliminate redundant YAML/XML configs and reduce the chance of misconfigured loggers. Key benefits:

  • Type safety: IDE autocompletion for loggers (e.g., $securityLogger->error()).
  • Fallback resilience: Automatically routes to a default logger if a channel is missing (configurable to NullLogger).
  • Future-proof: Works even without MonologBundle, and integrates cleanly with Symfony’s DI container.
  • Dev velocity: Faster onboarding for new hires and less context-switching during debugging.

Proposal: Pilot this in [Module X] to replace manual logger registration. If successful, we can roll it out to other services. The MIT license and minimal dependencies make it a safe bet."*

For Developers:

*"This bundle lets you autowire Monolog loggers like any other service, cutting down on repetitive services.yaml entries. For example:

// Before: Manual config in services.yaml
services:
    App\Service\AuditService:
        arguments:
            $logger: '@logger.audit'

// After: Autowire + type-hinting
class AuditService {
    public function __construct(
        private LoggerInterface $auditLogger, // Autowired!
        private LoggerInterface $appLogger    // Fallback if 'app' channel exists
    ) {}
}
- **No more hunting for logger service IDs** (e.g., `@logger.security`).
- **Fallback logic built-in**: If `$auditLogger` isn’t configured, it defaults to `@Psr\Log\LoggerInterface` (or `NullLogger`).
- **Works with `LoggerCollection`**: Inject a collection to access multiple channels dynamically.

*Try it*: Add the bundle to `composer.json`, and replace manual logger args with autowired properties. Zero breaking changes if you’re already using Monolog!"*
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony