P
P
postgresdev2019-10-23 21:53:35
symfony
postgresdev, 2019-10-23 21:53:35

How to use a monologue if there is no way to get a container?

I am doing an action in the transformer, there is no way to get the service container, how to write data to the log?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-10-23
@postgresdev

The symphony's monologue bundle wraps the monologue . You can abstract from both and make your own logger. And there already at least use the original, at least a monologue. But still implement PSR LoggerInterface.
Example from documentation:

<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

// add records to the log
$log->warning('Foo');
$log->error('Bar');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question