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

afoysal's avatar

500 error in Laravel but log folder is empty

I am working in a Client's Laravel project which version is 5.7.28. But I am not getting anything in storage/logs/ folder. I copied the .env.example to .env. I run composer install and php artisan key:generate. Some of my .env files configuration is like below

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:8ovbzfpWGsGTDyDIRWDO8VKObeXGyWqnMVw5KjTVJTc=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
BASE_URL=http://127.0.0.1:8000

I set permission 777 for all folders.

But I am getting 500 error. How can I solve the error.

0 likes
26 replies
Talinon's avatar

@afoysal Start off by checking your config/logging.php configuration, and check to see if you have LOG_CHANNEL defined in your .env file. It's possible its set to log to something other than the file system.

You might also get information from the Apache/Nginx webserver error log, too.

1 like
afoysal's avatar

Thanks @talinon for your reply. My config/logging.php is like below

<?php

use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler;

return [

/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/

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

/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
|                    "errorlog", "monolog",
|                    "custom", "stack"
|
*/

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

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

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

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

    'papertrail' => [
        'driver' => 'monolog',
        'level' => 'debug',
        'handler' => SyslogUdpHandler::class,
        'handler_with' => [
            'host' => env('PAPERTRAIL_URL'),
            'port' => env('PAPERTRAIL_PORT'),
        ],
    ],

    'stderr' => [
        'driver' => 'monolog',
        'handler' => StreamHandler::class,
        'formatter' => env('LOG_STDERR_FORMATTER'),
        'with' => [
            'stream' => 'php://stderr',
        ],
    ],

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

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

];

Below line is in my .env file

LOG_CHANNEL=stack

Sinnbeck's avatar

Are you certain that it is laravel that is throwing the error and not the webserver?

Does it say

500 | server error
1 like
afoysal's avatar

Thanks @sinnbeck . I don't know which one is throwing error. It is a ridiculous Laravel application.

Sinnbeck's avatar

Can you post an image of the error page. Just upload it to imgur.com

1 like
afoysal's avatar

Thanks @siangboon . Here is php version https://i.stack.imgur.com/RHTJU.png. The application is ridiculous. Application has 2 folder. 1 is zain_web and another is zain_api. Both has Laravel folder structure. It is a clients application. I am trying to install it in my local machine. Thanks.

Sinnbeck's avatar

That is definitely laravel :) Any chance you somehow got the cache from the production version?

try

php artisan optimize:clear
3 likes
Snapey's avatar

double check your permissions, particularly in storage/logs

1 like
afoysal's avatar

Thanks @snapey . I made permissions 777 for whole laravel repository. Thanks.

siangboon's avatar

the info.php is on http://127.0.0.1 which running on apache but the other images you shown that the application is running on http://127.0.0.1:8000, are you running and troubleshooting on the apache or localhost ?? if apache then check the apache log, if localhost then check the laravel log. it doesn't matter how many folders is it, i believe both are standalone application ,1 may the core application and another is for API resources... i suggest you to create a testing route and view to make sure the laravel is configured and running properly before test out the application functionality...

1 like
Sinnbeck's avatar

Try checking the webserver log instead. Something like /var/log/apache/error.log (replace apache with nginx if you run nginx)

1 like
afoysal's avatar

Thanks @sinnbeck . error.log is empty. My route is like below which I found in web.php

Route::view('/', 'common/web/wordpress');

View folder structure is like below

https://i.stack.imgur.com/yThwv.png

I found below code in wordpress.blade.php

  <?php
       echo file_get_contents('https://mallorcavilla-book.com');
  ?>

I am getting 500 error like below

https://i.stack.imgur.com/lufU5.png

Laravel storage/logs/ folder is empty

https://i.stack.imgur.com/a1c03.png

'/var/log/apache2/' folder is also empty

https://i.stack.imgur.com/PYmjK.png

siangboon's avatar

try comment out the line and write a new line to route it to the Laravel default welcome.blade.php..

#Route::view('/', 'common/web/wordpress');
Route::view('/', 'welcome');
1 like
philaMNE's avatar

Hmm.. if i remember, i had this issue but it was related to me not copying .env and then generating a key. If you have discord, add me there and we can take a look at it better! hidden

1 like
philaMNE's avatar

Try and get to the core of the problem and fix it (hopefully). We can use screenshare on discord or maybe teamviewer to try and find what is causing this error.

1 like
afoysal's avatar

Thanks @philamne . I tried for last 2 days. How can I exchange TeamViewer credentials ? Thanks.

siangboon's avatar

maybe you can share the full screenshot of composer.json.

1 like
afoysal's avatar

Thanks @philamne . Here is my composer.json.

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
    "framework",
    "laravel"
],
"license": "MIT",
"require": {
    "php": "^7.1.3",
    "doctrine/dbal": "^2.9",
    "fideloper/proxy": "^4.0",
    "guzzlehttp/guzzle": "^6.3",
    "intervention/image": "^2.4",
    "laravel/framework": "5.7.*",
    "laravel/tinker": "^1.0",
    "laravelcollective/html": "^5.7",
    "predis/predis": "^1.1",
    "spatie/laravel-permission": "^2.32",
    "unisharp/laravel-ckeditor": "^4.7"
},
"require-dev": {
    "beyondcode/laravel-dump-server": "^1.0",
    "filp/whoops": "^2.0",
    "fzaninotto/faker": "^1.4",
    "mockery/mockery": "^1.0",
    "nunomaduro/collision": "^2.0",
    "phpunit/phpunit": "^7.0"
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
},
"extra": {
    "laravel": {
        "dont-discover": []
    }
},
"autoload": {
    "psr-4": {
        "App\": "app/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ]
},
"autoload-dev": {
    "psr-4": {
        "Tests\": "tests/"
    }
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
    "post-autoload-dump": [
        "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate --ansi"
    ]
}

}

Esa's avatar

This Post seems 2 months older, but if any one runs into this issue.

after clearing cache.

remove the laravel.log file by running: rm storage/logs/laravel.log

now let the laravel application creates the log file, and you should be good.

Eissa.

5 likes

Please or to participate in this conversation.