Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dustydiamond's avatar

Logging not working properly

Hi, I have a problem with logging in Laravel. I'm using Laravel 10 with Jetstream (Laravel v10.45.1 (PHP v8.3.3) to be precise)

Now my problem is, that none of my tries to log into logfiles via Log:: works.

For example: I have a Usercontroller, where I update the users roles (via spatie) and want to log that event.

public function update(Request $request)
    {
        $validatedData = $request->validate([
            'user_id' => 'required|exists:users,id',
            'roles' => 'array',
        ]);

        $user = User::findOrFail($request->user_id);

        $user->roles()->sync($request->input('roles', []));
        Log::info('Edited Info for user {givenName} {sn}', ['givenName' => $user->givenName, 'sn' => $user->sn]);

        return redirect()->back()->with('success', 'User successfully updated');
    }

now this Log-Message never gets created in the logfiles, but laravel isn't throwing an error, so I guess the syntax is correct. The weird part is, that errors generated from the console get logged. For example if I try to call php artisan pail while not having pail installed I get the error message written to the logfiles.

Below my logging.php (excerpts):

'default' => env('LOG_CHANNEL', 'stack'),

'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'daily'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => env('LOG_SINGLE_PATH', 'storage/logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'permissions' => 0775,
            'replace_placeholders' => true,
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => env('LOG_DAILY_PATH', 'storage/logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'permissions' => 0775,
            'days' => 14,
            'replace_placeholders' => true,
        ],

		[...]

        'emergency' => [
            'path' => env('LOG_EMERGENCY_PATH', 'storage/logs/laravel.log'),
        ],
    ],

and corresponding .env parts:

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
LOG_SINGLE_PATH="storage/logs/laravel.log"
LOG_DAILY_PATH="storage/logs/laravel.log"
LOG_EMERGENCY_PATH="storage/logs/laravel-emergency.log"

I would appreciate any help with this. :)

0 likes
6 replies
tisuchi's avatar

@dustydiamond Can you make sure that permission for storage? e.g. sudo chmod -R 775 storage/logs

Also, clearing the config?

php artisan config:clear
gych's avatar
gych
Best Answer
Level 29

It might be because of your configuration, seems like the storage_path() helper method is removed

Try to update config like this:

'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single', 'daily'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path(env('LOG_SINGLE_PATH', 'logs/laravel.log')),
            'level' => env('LOG_LEVEL', 'debug'),
            'permissions' => 0775,
            'replace_placeholders' => true,
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path(env('LOG_DAILY_PATH', 'logs/laravel.log')),
            'level' => env('LOG_LEVEL', 'debug'),
            'permissions' => 0775,
            'days' => 14,
            'replace_placeholders' => true,
        ],

		[...]

        'emergency' => [
            'path' => storage_path(env('LOG_EMERGENCY_PATH', 'logs/laravel.log')),
        ],

And update this in your ENV

LOG_SINGLE_PATH="logs/laravel.log"
LOG_DAILY_PATH="logs/laravel.log"
LOG_EMERGENCY_PATH="logs/laravel-emergency.log"
1 like
dustydiamond's avatar

@gych I can see that point, but i would then to have a seperate area within logging.php to config for my production env, where i can't/don't want to have the logfiles in storage path, but i guess this would be the way. With storage_path() helper added it works for now, thanks.

gych's avatar

@dustydiamond No problem :) Please don't forget to close your thread by selecting the best reply.

If you want to use a different path in production its possible but you'll have to add the full path if you don't want to use the storage_path() helper function.

1 like
Snapey's avatar

as mentioned by @tisuchi if you cause the logfile to be created by your user account then your webserver may not be able to write to it.

check the owner name and permissions on the file

The usual solution is to make sure log files are group writeable and that you and the webserver are in the same group

Please or to participate in this conversation.