cleatsquad / magento2-logstream
A Magento 2 module to redirect all logs to StdOut, ideal for dockerized environments.
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Type:magento2-module
pkg:composer/cleatsquad/magento2-logstream
Requires
- php: >=8.1
- magento/framework: *
- magento/module-store: *
- monolog/monolog: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-12-12 12:30:25 UTC
README
A Magento 2 module that redirects all Magento logs to StdOut, making it ideal for Docker and containerized environments. This enables seamless log aggregation into external systems (ELK, Datadog, CloudWatch, etc.) without managing Magento-specific log files.
Badges
✨ Features
- 🐳 Docker-ready: Logs to StdOut for seamless container integration.
- 📊 External Log Aggregation: Works with ELK, Datadog, CloudWatch, Splunk, etc.
- ⚙️ Configurable Log Levels: Set log level (DEBUG, INFO, WARNING, ERROR, etc.) from admin panel.
- 🛡️ Clean DI Override: Uses Magento dependency injection, no core hacks.
- 🎯 Zero Configuration: Works out of the box after installation.
- 🔄 Real-time Logs: Immediate log output without file I/O delays.
- 🧩 Monolog Integration: Built on Monolog's StreamHandler.
📦 Installation
You can install this module using Composer (recommended) or manually.
🔹 1. Install via Composer (recommended)
-
Download the package
composer require cleatsquad/magento2-logstream
-
Enable the module
bin/magento module:enable CleatSquad_LogStream bin/magento setup:upgrade
🔹 2. Manual Installation (app/code)
-
Copy the module to your Magento installation
app/code/CleatSquad/LogStream/ -
Enable the module
bin/magento module:enable CleatSquad_LogStream bin/magento setup:upgrade
🚀 Usage
Once installed, the module will automatically redirect all Magento logs to StdOut without any additional configuration.
Viewing Logs in Docker
docker logs -f <container_name>
Example Log Output
[2024-01-15 10:30:45] main.INFO: User login successful {"username":"admin"} []
[2024-01-15 10:30:46] main.WARNING: Cache miss for product 123 [] []
⚙️ Configuration
To configure the log level for the CleatSquad Magento2 LogStream module, follow these steps in the Magento admin interface:
Setting the Log Level
- Navigate to
Stores > Configurationin the admin panel sidebar. - Under the
Generalsection, find and open theLogginggroup. - Select the desired log level from the
Log Leveldropdown menu.
Available Log Levels
| Level | Value | Description |
|---|---|---|
| DEBUG | 100 | Detailed debug information |
| INFO | 200 | Interesting events (default) |
| NOTICE | 250 | Normal but significant events |
| WARNING | 300 | Exceptional occurrences that are not errors |
| ERROR | 400 | Runtime errors |
| CRITICAL | 500 | Critical conditions |
| ALERT | 550 | Action must be taken immediately |
| EMERGENCY | 600 | System is unusable |
Changes will take effect immediately after saving the configuration.
🔧 Technical Details
Architecture
This module works by:
- Overriding Monolog's handler: Adds a custom
StdoutHandlerto Magento's logger via DI. - Streaming to php://stdout: All log messages are written directly to standard output.
- Respecting log levels: Only logs at or above the configured level are output.
DI Configuration
<type name="Magento\Framework\Logger\Monolog"> <arguments> <argument name="handlers" xsi:type="array"> <item name="stdout" xsi:type="object">CleatSquad\LogStream\Logger\StdoutHandler</item> </argument> </arguments> </type>
🔄 Upgrading
To upgrade the module to the latest version, run:
composer update cleatsquad/magento2-logstream bin/magento setup:upgrade
📋 Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
🔗 Follow
For the latest updates and new features, follow our GitHub repository: cleatsquad/magento2-logstream.
🤝 Contributing
Contributions to CleatSquad_LogStream are always welcome. You can contribute in different ways:
- Report Issues: Report bugs and suggest new features.
- Fix Bugs: Submit pull requests with bug fixes.
- Add Features: Develop new features and submit them as pull requests.
- Improve Documentation: Help new users by improving or translating the documentation.
Issues and pull requests are welcome.
GitHub: https://github.com/CleatSquad/magento2-logstream
💬 Support
If you need help or have a question, you can:
- Open an issue through GitHub for bug reports and feature requests.
- Check the Magento Community Forums for general questions and support on Magento.
- Check on Magento Stack Exchange for general programming questions.
👤 Authors
- Mohamed EL Mrabet - Initial work - mimou78
See also the list of contributors who participated in this project.
📜 License
This project is licensed under the MIT License - see the LICENSE.md file for details.
🙏 Acknowledgments
This module is powered by the excellent Monolog library:
➡️ https://github.com/Seldaek/monolog
- Magento Community
- Anyone who contributes to the open-source community
© 2024 - CleatSquad (https://cleatsquad.dev)