Closed Lotuashvili closed 3 weeks ago
🤔️ Maybe in octane you need to use Log::shareContext(['global_context' => 'value']);
@sy-records Yeah that works!
Thanks @sy-records
@driesvints I didn't close this issue on purpose, because that is a workaround and not a solution/fix. In this case I really needed it for logging purpose, but I will also need Context as a data storing mechanism for different parts of application. It's still going to be cleared before getting to logs. So I would really suggest to debug why it's being cleared by Octane.
@Lotuashvili ah gotcha. I thought you were happy with the workaround. I'll try to see if this one is solvable.
Thanks for reporting this one.
I've opened a PR to fix this issue: https://github.com/laravel/octane/pull/910
Octane Version
2.3.7
Laravel Version
11.10
PHP Version
8.3
What server type are you using?
Swoole
Server Version
AWS
Database Driver & Version
MySQL 8
Description
While using Laravel Octane and Context variables, it gets cleared before the log entry is created. I can successfully access my data by
Context::get('name')
in the app, but it's not being included in logs.I tried to run this application without Octane (
php artisan serve
), and the context is working as expected.Steps To Reproduce
Create a test route in
web.php
: (As shown here)In
laravel.log
file, you will get onlylocal_data
.