I'm using Lumen 5.3 and I'm not sure on how i should implement debug mode.
In .env, i have this:
APP_DEBUG=true
In my script I have this:
Log::debug("Test");
So it will log in storage/logs/lumen.log when i run the script which is right.
I have made the value of APP_DEBUG=false and yet the Log::debug line I put keeps logging in lumen.log. How to turn off the log in debug level or is any other way to implement what I'm expecting to happen?
Update for Lumen
Apologies I was not reading properly, for Lumen 5.3 you can override the logging inside bootstrap/app.php
pushing your own log handler.
Add the following towards the bottom of your app.php file, before you return $app
:
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter\LineFormatter;
...
$app->configureMonologUsing(function($monolog) {
$handler = new StreamHandler(storage_path('logs/lumen.log'), Logger::ERROR);
$handler->setFormatter(new LineFormatter(null, null, true, true));
$monolog->pushHandler($handler);
return $monolog;
});
In the code example you will then only be logging ERROR levels. You will need to import the namespaces.
To disable logging completely, you can do the following
$app->configureMonologUsing(function($monolog) {
$monolog->pushHandler(new NullHandler(Logger::DEBUG));
return $monolog;
});
Leaving the original Laravel 5.3 answer
For laravel 5.3 the log level is configured inside app/config.php
.
The default generally is
'log_level' => env('APP_LOG_LEVEL', 'debug'),
So if you change your APP_LOG_LEVEL
inside the .env to something like error
on your production server it will not log debug message sprinkled throughout the app.
Inside your .env
APP_LOG_LEVEL=error