praxigento / mage2_ext_logging
Monolog Cascade integration to Magento 2.
Installs: 2 614
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 4
Forks: 4
Open Issues: 0
Type:magento2-module
Requires
- php: >=5.5
- symfony/filesystem: *
- theorchard/monolog-cascade: *
README
Installation
Add to your project's composer.json
:
"require": {
"praxigento/mage2_ext_logging": "~0.1"
}
Usage
Default configuration file is in var/log/logging.yaml
(see src/etc/di.xml
).
Get logger with ObjectManager:
public function __construct(
\Psr\Log\LoggerInterface $logger,
...
) {
$this->_logger = $logger;
...
}
Then log your messages:
$this->_logger->info("'Get account' operation is called.");
Configuration sample
disable_existing_loggers: true
formatters:
dashed:
class: Monolog\Formatter\LineFormatter
format: "%datetime%-%channel%.%level_name% - %message%\n"
handlers:
debug:
class: Monolog\Handler\StreamHandler
level: DEBUG
formatter: dashed
stream: /.../var/log/cascade_debug.log
system:
class: Monolog\Handler\StreamHandler
level: INFO
formatter: dashed
stream: /.../var/log/cascade_system.log
exception:
class: Monolog\Handler\StreamHandler
level: EMERGENCY
formatter: dashed
stream: /.../log/cascade_exception.log
processors:
web_processor:
class: Monolog\Processor\WebProcessor
loggers:
main:
handlers: [debug, system, exception]
processors: [web_processor]