monolog: "Object of class Monolog\Level could not be converted to int"

Monolog version 3.2

I’m experiencing strange behavior from Monolog when using any logging method.

ErrorException: Warning: Object of class Monolog\Level could not be converted to int #12 /vendor/monolog/monolog/src/Monolog/Logger.php(314): Monolog\Logger::addRecord #11 /vendor/monolog/monolog/src/Monolog/Logger.php(614): Monolog\Logger::error #10 /src/MyFile.php(107): Service\MyFile::foobar

Inside foobar method I’m just executing $this->logger->error('lorem ipsum');

I am still trying to understand why this is happening. I tried to reproduce the steps in 3v4l.org and on my local env, but this only happens on my prod env.

Can this be related to this package, or is this something with opcache, maybe? Any idea how to fix this?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Yeah sorry but we are not going to patch this like that, it makes no sense. They should make sure to update their support to include Monolog 3.

@NavyCoat @sakarikl @Seldaek

We fixed the behaviour identified in this issue by rolling out general support for Monolog 3 with Instana PHP Tracer 3.0.0.

We are looking at the issue and investigating a possible fix for the Instana PHP Tracer.

I bet that for us Instana hooks into monolog in PHP process and now does it using old interface.

addRecord has an argument type being int|Level, so PHP should not try to convert the argument to int