user1978109
user1978109

Reputation: 737

Laravel appends date to log files

I have two identical Laravel environments running 5.8 showing different behavior on how its storing logs.

Production storage/logs/laravel.log
QA         storage/logs/laravel-2020-03-06.log

Both have the same config/logging.php configuration... Am I missing a configuration value somewhere? Why are they different formats?

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['daily', 'slack'],
    ],

    'single' => [
        'driver' => 'single',
        'path' => storage_path('logs/laravel.log'),
        'level' => 'debug',
    ],

    'daily' => [
        'driver' => 'daily',
        'path' => storage_path('logs/laravel.log'),
        'level' => 'debug',
        'days' => 7,
    ],

    'slack' => [
        'driver' => 'slack',
        'url' => env('LOG_SLACK_WEBHOOK_URL'),
        'username' => 'Laravel Log',
        'emoji' => ':boom:',
        'level' => 'notice',
    ],

    'stderr' => [
        'driver' => 'monolog',
        'handler' => StreamHandler::class,
        'with' => [
            'stream' => 'php://stderr',
        ],
    ],

    'syslog' => [
        'driver' => 'syslog',
        'level' => 'debug',
    ],

    'errorlog' => [
        'driver' => 'errorlog',
        'level' => 'debug',
    ],
],

Upvotes: 1

Views: 1581

Answers (2)

mrhn
mrhn

Reputation: 18916

Your default is probably different, the default setting is in logging.php, a new project i have installed it look like this.

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

This mean you env is not set the same in your two environments.

To get laravel.log style, put the following in the .env

LOG_CHANNEL=single

To get date appended like laravel-2020-03-06.log.

LOG_CHANNEL=daily

Upvotes: 4

RAJEESH PM
RAJEESH PM

Reputation: 83

Change the value in config/app.php "log" field value to "single"

Upvotes: 0

Related Questions