Reputation: 73
For some reason laravel keeps writing log statements to the laravel log after I have set APP_DEBUG=false in my .env file.
I have the following log statement:
Log::debug("testmessage : BEGIN");
I have confirmed that the environment variable is being read by Laravel. I did this using this command that writes to the error log:
error_log("APP_DEBUG : " . env('APP_DEBUG', false));
It displays nothing if APP_DEBUG is false and '1' if it is true
I have cleared the cache :
gavin@gavin-VirtualBox:/var/www/hipengage$ **php artisan config:cache**
Configuration cache cleared!
Configuration cached successfully!
gavin@gavin-VirtualBox:/var/www/hipengage$ **php artisan cache:clear**
Application cache cleared!
I have restarted apache
My .env file looks like this:
APP_ENV=local
APP_DEBUG=false
APP_KEY=*********************************
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Anything I am missing here? Any help much appreciated.
Upvotes: 2
Views: 7705
Reputation: 642
Go to /config/app.php and see for
'debug' => env('APP_DEBUG', 'false'),
Upvotes: 0
Reputation: 17658
APP_DEBUG
is used to limit the amount of error details your application displays through the browser.
It should not be confused that it controls the logging in log file.
To log only when APP_DEBUG
is true
then you can check it's value and do that as:
if (config('app.debug'))
{
Log::debug("some debug text");
}
Or you can create a helper function like:
function some_cool_name($log)
{
if (config('app.debug')) {
Log::debug($log);
}
}
And then you can use it anywhere:
some_cool_name('some debug text');
Upvotes: 2