[GH-ISSUE #1965] add "__set_state" to Handlers to allow laravel config cache #848

Open
opened 2026-03-04 03:01:26 +03:00 by kerem · 4 comments
Owner

Originally created by @Curicows on GitHub (Apr 22, 2025).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1965

I have a project that uses the Laravel framework. I'm using the TelegramBotHandler to handle logs.

"telegram" => [
    'driver'  => 'monolog',
    'handler' => FilterHandler::class,
    'tap' => [TelegramFormatter::class],
    'level' => "debug",
    'with' => [
        'handler' => new TelegramBotHandler(
            apiKey: env('TELEGRAM_API_KEY', ""),
            channel: env('TELEGRAM_CHANNEL', ""),
            level: Level::Debug,
            parseMode: "MarkdownV2"
        )
    ]
],

While it works perfect in the local environment, when I try to cache the Laravel config an error is thrown:

laravel@ubuntu:/path/to/project$ artisan optimize

   INFO  Caching framework bootstrap, configuration, and metadata.  

  config .............................................................................................................................. 76.17ms FAIL
[2025-04-22 17:28:06] development.ERROR: Your configuration files are not serializable. {"exception":"[object] (LogicException(code: 0): Your configuration files are not serializable. at /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:72)
[stacktrace]
#0 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ConfigCacheCommand->handle()
#1 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}()
#2 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure()
#3 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#4 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call()
#5 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call()
#6 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute()
#7 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run()
#8 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Illuminate\\Console\\Command->run()
#9 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(41): Illuminate\\Console\\Command->runCommand()
#10 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(53): Illuminate\\Console\\Command->callSilent()
#11 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\Command->callSilently()
#12 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php(41): Illuminate\\Foundation\\Console\\OptimizeCommand->{closure:Illuminate\\Foundation\\Console\\OptimizeCommand::handle():48}()
#13 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Factory.php(59): Illuminate\\Console\\View\\Components\\Task->render()
#14 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\View\\Components\\Factory->__call()
#15 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\OptimizeCommand->handle()
#16 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}()
#17 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure()
#18 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#19 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call()
#20 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call()
#21 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute()
#22 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run()
#23 /path/to/project/vendor/symfony/console/Application.php(1094): Illuminate\\Console\\Command->run()
#24 /path/to/project/vendor/symfony/console/Application.php(342): Symfony\\Component\\Console\\Application->doRunCommand()
#25 /path/to/project/vendor/symfony/console/Application.php(193): Symfony\\Component\\Console\\Application->doRun()
#26 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run()
#27 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1234): Illuminate\\Foundation\\Console\\Kernel->handle()
#28 /path/to/project/artisan(13): Illuminate\\Foundation\\Application->handleCommand()
#29 {main}

[previous exception] [object] (Error(code: 0): Call to undefined method Monolog\\Handler\\TelegramBotHandler::__set_state() at /path/to/project/bootstrap/cache/config.php:902)
[stacktrace]
#0 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php(68): require()
#1 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ConfigCacheCommand->handle()
#2 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}()
#3 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure()
#4 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#5 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call()
#6 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call()
#7 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute()
#8 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run()
#9 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Illuminate\\Console\\Command->run()
#10 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(41): Illuminate\\Console\\Command->runCommand()
#11 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(53): Illuminate\\Console\\Command->callSilent()
#12 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\Command->callSilently()
#13 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php(41): Illuminate\\Foundation\\Console\\OptimizeCommand->{closure:Illuminate\\Foundation\\Console\\OptimizeCommand::handle():48}()
#14 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Factory.php(59): Illuminate\\Console\\View\\Components\\Task->render()
#15 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\View\\Components\\Factory->__call()
#16 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\OptimizeCommand->handle()
#17 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}()
#18 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure()
#19 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#20 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call()
#21 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call()
#22 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute()
#23 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run()
#24 /path/to/project/vendor/symfony/console/Application.php(1094): Illuminate\\Console\\Command->run()
#25 /path/to/project/vendor/symfony/console/Application.php(342): Symfony\\Component\\Console\\Application->doRunCommand()
#26 /path/to/project/vendor/symfony/console/Application.php(193): Symfony\\Component\\Console\\Application->doRun()
#27 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run()
#28 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1234): Illuminate\\Foundation\\Console\\Kernel->handle()
#29 /path/to/project/artisan(13): Illuminate\\Foundation\\Application->handleCommand()
#30 {main}
"} 

   LogicException 

  Your configuration files are not serializable.

  at vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:72
     68▕             require $configPath;
     69▕         } catch (Throwable $e) {
     70▕             $this->files->delete($configPath);
     71▕ 
  ➜  72▕             throw new LogicException('Your configuration files are not serializable.', 0, $e);
     73▕         }
     74▕ 
     75▕         $this->components->info('Configuration cached successfully.');
     76▕     }

  1   bootstrap/cache/config.php:902
      Error::("Call to undefined method Monolog\Handler\TelegramBotHandler::__set_state()")
      +29 vendor frames 

  31  artisan:13
      Illuminate\Foundation\Application::handleCommand()

Inspecting the generated file before the "LogicException" has been thrown resulted in this cache:

'telegram' => 
      array (
        'driver' => 'monolog',
        'handler' => 'Monolog\\Handler\\FilterHandler',
        'tap' => 
        array (
          0 => 'App\\Log\\TelegramFormatter',
        ),
        'level' => 'debug',
        'with' => 
        array (
          'handler' => 
          \Monolog\Handler\TelegramBotHandler::__set_state(array(
             'level' => 
            \Monolog\Level::Debug,
             'bubble' => true,
             'processors' => 
            array (
            ),
             'formatter' => NULL,
             'apiKey' => 'redacted',
             'channel' => '@redacted',
             'parseMode' => 'MarkdownV2',
             'disableWebPagePreview' => NULL,
             'disableNotification' => NULL,
             'splitLongMessages' => false,
             'delayBetweenMessages' => false,
             'topic' => NULL,
          )),
        ),
      ),

The error occurs because when Laravel cache the config that directly instantiates an object it is transformed to call the static magic method "__set_state" of the class used. But an error is thrown because the Handler classes doesn't have this magic method.

I'm able to create a pull request to resolve that and if more information is needed I can provide it, thanks for the attention.

Originally created by @Curicows on GitHub (Apr 22, 2025). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1965 I have a project that uses the Laravel framework. I'm using the **TelegramBotHandler** to handle logs. ```php "telegram" => [ 'driver' => 'monolog', 'handler' => FilterHandler::class, 'tap' => [TelegramFormatter::class], 'level' => "debug", 'with' => [ 'handler' => new TelegramBotHandler( apiKey: env('TELEGRAM_API_KEY', ""), channel: env('TELEGRAM_CHANNEL', ""), level: Level::Debug, parseMode: "MarkdownV2" ) ] ], ``` While it works perfect in the local environment, when I try to cache the Laravel config an error is thrown: ``` laravel@ubuntu:/path/to/project$ artisan optimize INFO Caching framework bootstrap, configuration, and metadata. config .............................................................................................................................. 76.17ms FAIL [2025-04-22 17:28:06] development.ERROR: Your configuration files are not serializable. {"exception":"[object] (LogicException(code: 0): Your configuration files are not serializable. at /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:72) [stacktrace] #0 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ConfigCacheCommand->handle() #1 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}() #2 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure() #3 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #4 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call() #5 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #6 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute() #7 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run() #8 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Illuminate\\Console\\Command->run() #9 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(41): Illuminate\\Console\\Command->runCommand() #10 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(53): Illuminate\\Console\\Command->callSilent() #11 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\Command->callSilently() #12 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php(41): Illuminate\\Foundation\\Console\\OptimizeCommand->{closure:Illuminate\\Foundation\\Console\\OptimizeCommand::handle():48}() #13 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Factory.php(59): Illuminate\\Console\\View\\Components\\Task->render() #14 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\View\\Components\\Factory->__call() #15 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\OptimizeCommand->handle() #16 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}() #17 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure() #18 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #19 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call() #20 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #21 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute() #22 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run() #23 /path/to/project/vendor/symfony/console/Application.php(1094): Illuminate\\Console\\Command->run() #24 /path/to/project/vendor/symfony/console/Application.php(342): Symfony\\Component\\Console\\Application->doRunCommand() #25 /path/to/project/vendor/symfony/console/Application.php(193): Symfony\\Component\\Console\\Application->doRun() #26 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run() #27 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1234): Illuminate\\Foundation\\Console\\Kernel->handle() #28 /path/to/project/artisan(13): Illuminate\\Foundation\\Application->handleCommand() #29 {main} [previous exception] [object] (Error(code: 0): Call to undefined method Monolog\\Handler\\TelegramBotHandler::__set_state() at /path/to/project/bootstrap/cache/config.php:902) [stacktrace] #0 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php(68): require() #1 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\ConfigCacheCommand->handle() #2 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}() #3 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure() #4 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #5 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call() #6 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #7 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute() #8 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run() #9 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Illuminate\\Console\\Command->run() #10 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(41): Illuminate\\Console\\Command->runCommand() #11 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(53): Illuminate\\Console\\Command->callSilent() #12 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\Command->callSilently() #13 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php(41): Illuminate\\Foundation\\Console\\OptimizeCommand->{closure:Illuminate\\Foundation\\Console\\OptimizeCommand::handle():48}() #14 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/View/Components/Factory.php(59): Illuminate\\Console\\View\\Components\\Task->render() #15 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php(48): Illuminate\\Console\\View\\Components\\Factory->__call() #16 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\OptimizeCommand->handle() #17 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::{closure:Illuminate\\Container\\BoundMethod::call():35}() #18 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\\Container\\Util::unwrapIfClosure() #19 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #20 /path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\BoundMethod::call() #21 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\\Container\\Container->call() #22 /path/to/project/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute() #23 /path/to/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\\Component\\Console\\Command\\Command->run() #24 /path/to/project/vendor/symfony/console/Application.php(1094): Illuminate\\Console\\Command->run() #25 /path/to/project/vendor/symfony/console/Application.php(342): Symfony\\Component\\Console\\Application->doRunCommand() #26 /path/to/project/vendor/symfony/console/Application.php(193): Symfony\\Component\\Console\\Application->doRun() #27 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run() #28 /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1234): Illuminate\\Foundation\\Console\\Kernel->handle() #29 /path/to/project/artisan(13): Illuminate\\Foundation\\Application->handleCommand() #30 {main} "} LogicException Your configuration files are not serializable. at vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigCacheCommand.php:72 68▕ require $configPath; 69▕ } catch (Throwable $e) { 70▕ $this->files->delete($configPath); 71▕ ➜ 72▕ throw new LogicException('Your configuration files are not serializable.', 0, $e); 73▕ } 74▕ 75▕ $this->components->info('Configuration cached successfully.'); 76▕ } 1 bootstrap/cache/config.php:902 Error::("Call to undefined method Monolog\Handler\TelegramBotHandler::__set_state()") +29 vendor frames 31 artisan:13 Illuminate\Foundation\Application::handleCommand() ``` Inspecting the generated file before the **"LogicException"** has been thrown resulted in this cache: ``` 'telegram' => array ( 'driver' => 'monolog', 'handler' => 'Monolog\\Handler\\FilterHandler', 'tap' => array ( 0 => 'App\\Log\\TelegramFormatter', ), 'level' => 'debug', 'with' => array ( 'handler' => \Monolog\Handler\TelegramBotHandler::__set_state(array( 'level' => \Monolog\Level::Debug, 'bubble' => true, 'processors' => array ( ), 'formatter' => NULL, 'apiKey' => 'redacted', 'channel' => '@redacted', 'parseMode' => 'MarkdownV2', 'disableWebPagePreview' => NULL, 'disableNotification' => NULL, 'splitLongMessages' => false, 'delayBetweenMessages' => false, 'topic' => NULL, )), ), ), ``` The error occurs because when Laravel cache the config that directly instantiates an object it is transformed to call the static magic method "__set_state" of the class used. But an error is thrown because the Handler classes doesn't have this magic method. I'm able to create a pull request to resolve that and if more information is needed I can provide it, thanks for the attention.
Author
Owner

@Seldaek commented on GitHub (Oct 23, 2025):

I'm not sure what we can do about this. If __set_state doesn't exist I'd think Laravel's serializer should not attempt to call it. If it is due to a specific value we can try to resolve it but I'm not sure what that would be..

<!-- gh-comment-id:3438781346 --> @Seldaek commented on GitHub (Oct 23, 2025): I'm not sure what we can do about this. If __set_state doesn't exist I'd think Laravel's serializer should not attempt to call it. If it is due to a specific value we can try to resolve it but I'm not sure what that would be..
Author
Owner

@dmohns commented on GitHub (Nov 10, 2025):

Also encountering this issues. Two questions here

  1. @Curicows Are you saying you have a way to fix this issue? Could you share this?
  2. Would there be a way, where FilterHandler can be change to also accept a class-string and add a new option, i.e. handler_parameters that will be used to instantiate it?
<!-- gh-comment-id:3510795309 --> @dmohns commented on GitHub (Nov 10, 2025): Also encountering this issues. Two questions here 1. @Curicows Are you saying you have a way to fix this issue? Could you share this? 2. Would there be a way, where `FilterHandler` can be change to also accept a `class-string` and add a new option, i.e. `handler_parameters` that will be used to instantiate it?
Author
Owner

@Seldaek commented on GitHub (Nov 10, 2025):

I am not sure what you mean.. FilterHandler receives a handler instances like all other wrapping handlers. I don't see it as practical to change this to a class + parameters for all wrapping handlers.

<!-- gh-comment-id:3510817334 --> @Seldaek commented on GitHub (Nov 10, 2025): I am not sure what you mean.. FilterHandler receives a handler instances like all other [wrapping handlers](https://github.com/Seldaek/monolog/blob/main/doc/02-handlers-formatters-processors.md#wrappers--special-handlers). I don't see it as practical to change this to a class + parameters for all wrapping handlers.
Author
Owner

@dmohns commented on GitHub (Nov 10, 2025):

I am not sure what you mean.. FilterHandler receives a handler instances like all other wrapping handlers. I don't see it as practical to change this to a class + parameters for all wrapping handlers.

It was just a thought 😉 But yeah, if it's breaking the entire design of this library probably not worth to think about some changes that solve an issue that's really on Laravel side.

Laravel seems to do serialisation simply with var_export

        $this->files->put(
            $configPath,
            '<?php return '.var_export($config, true).';'.PHP_EOL
        );

By adding __set_state to the underlying handler (StreamHandler in my case) I can get it to work (well... at least no throw an error), but similar to above: It's probably not worth for this library to maintain __set_state just so Laravel can use var_export for serialisation.

<!-- gh-comment-id:3511322912 --> @dmohns commented on GitHub (Nov 10, 2025): > I am not sure what you mean.. FilterHandler receives a handler instances like all other [wrapping handlers](https://github.com/Seldaek/monolog/blob/main/doc/02-handlers-formatters-processors.md#wrappers--special-handlers). I don't see it as practical to change this to a class + parameters for all wrapping handlers. It was just a thought 😉 But yeah, if it's breaking the entire design of this library probably not worth to think about some changes that solve an issue that's really on Laravel side. Laravel seems to do serialisation simply with `var_export` ``` $this->files->put( $configPath, '<?php return '.var_export($config, true).';'.PHP_EOL ); ``` By adding `__set_state` to the underlying handler (`StreamHandler` in my case) I can get it to work (well... at least no throw an error), but similar to above: It's probably not worth for this library to maintain `__set_state` just so Laravel can use `var_export` for serialisation.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#848
No description provided.