can anybody help on this :
(Psr\Log\InvalidArgumentException): Level "" is not defined, use one
of: 100, 200, 250, 300, 400, 500, 550, 600
vendor\monolog\monolog\src\Monolog\Logger.php(256):
Monolog\Logger::getLevelName(NULL)
lib\internal\Magento\Framework\Logger\Monolog.php(24):
Monolog\Logger->addRecord(NULL, 'Tagalys Request…', Array)
This is how i have used logger
protected $logger;
public function __construct(
\Psr\Log\LoggerInterface $logger,
) {
$this->logger = $logger;
}
public function xyz(){
$this->logger->log(null, 'Tagalys Request Object: '.json_encode($payload));
}
I am not getting any log files
Best Answer
When you use the
\Psr\Log\LoggerInterface
the first parameter must be a level of log.Different levels can be found under
Psr\Log\LogLevel
:So if you want to log for example a debug information you'll have to call:
To avoid having to specify the level of log, the class provides one method per level so instead of the code above, you can also do:
The other methods available are:
emergency()
alert()
critical()
error()
warning()
notice()
info()
Using this class you cannot specify a custom log file.
If you want to do so you can use the following code: