Skip to content

Context gets cleared before logging #907

@Lotuashvili

Description

@Lotuashvili

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)

use Illuminate\Support\Facades\Context;
use Illuminate\Support\Facades\Log;

Route::get('test', function () {
    Context::add('global_context', 'value');

    Log::info('test', ['local_data' => 'local']);

    return response('test');
});

In laravel.log file, you will get only local_data.

[2024-06-15 10:45:51] local.INFO: test {"local_data":true}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions