I cannot disable Laravel debug logging? - laravel

I kept running the debug logging level for some time for my application also on prod, after now 2 weeks, I wanted to disable it. So I went ahead and opend the .env variable and set APP_DEBUG=false
I did a php artisan down, php artisan cache:clear, then php artisan config:clear, php artisan config:cache and brought it back up. To be fully safe here.
I went back in the log file after a minute or so and still saw production.DEBUG appearing.
I then retried all the steps, checked the config/app.php file and made sure that nothing is wrong in there. But everything looks fine.
Then I went to my local environment and tried the same but to my surprise the application still keeps logging debug messages also on local!
I cannot get it disabled!
What I tried:
php artisan config:clear / :cache / cache:clear optimize:clear / down / up ...
I checked the app.php file, the config/logging.php but all looks fine
APP_ENV=production, APP_DEBUG=false
Then to my surprise I tried something:
I changed LOG_LEVEL=info in the .env file -> no change
I opened the config/logging.php and went to the daily section (because LOG_CHANNEL=daily) and set the 'level' entry to 'info' => IT WORKS! both on PROD and LOCAL
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'info',
'days' => 21,
],
Can someone explain to me, why this is happening?
I was under the impression that the APP_DEBUG and the LOG_LEVEL should be the key indicators for Laravel but somehow they aren't?!
Might that be related to the LARAVEL DEBUGBAR? I have it installed.
Laravel version 7, php 7.4 (local Homestead, prod apache)

Related

Laravel with heroku -> how do I fix app_key problem?

I have been working on a Laravel application and started to push to Heroku for production testing. I am following the Heroku documentation for a laravel application and am getting the following error:
"The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."
I have been searching for similiar problems and solutions and all of which I ahve tried; they say to run:
php artisan config:clear
php artisan config:cache
even generate a new key sometimes. None of this works though. I do have a .env as well as the .env.exmaple.
this is in the app.php:
'key' => env('APP_KEY', 'hApwwlSuskUu66CxJTWzCKS17fkExEkodmJiVXbMf0Q='),
'cipher' => 'AES-256-CBC',
and equally the .env has this line after the cache:
APP_KEY=base64:hApwwlSuskUu66CxJTWzCKS17fkExEkodmJiVXbMf0Q=
What else do I do? I followed the Heroku documentation to the letter and beyond.
Reference:
Laravel 6.18.3
php: 7.3.2
composer: 1.9.3
heroku 7.22.2
Try this in your app.php
'key' => env('APP_KEY', $_ENV['APP_KEY'])
or you can also try this
app.php
'key' => env('APP_KEY')
then run
heroku config:set APP_KEY=$(php artisan --no-ansi key:generate --show)

Laravel can't change config value

I found the problem, i'll try to use a homestead or docker.
if i restart php artisan serve the changed values are applied.
Same my post: Laravel can't change config value
I make route
Route::get('/config', function () {
return dd(config('app'));
});
And cant change my config/app.php, for example i want to change
'url' => env('APP_URL', 'test'),
'client_url' => env('APP_CLIENT_URL', 'test'),
I set
APP_CLIENT_URL=str1
APP_URL=str2
and there is something inexplicable:
My "url" => "http://127.0.0.1:8000" !!! not default 'test' or from .env, I did not set such a value.
My client_url contains the old value, after I cached the config.
This is not production, i accidentally run config:cache, but after i remove all cache from bootsrap/cache, storage/framework/cache and running cache:clear, config:clear.
After running config:cache values from the .env were put in config, but I do not want to constantly change cache in development and it is not recommended in the documentation.
How can I easily change .env in in developing?

Laravel - 'Auth guard [admin] is not defined.'

This is a fresh copy of Laravel 5.6.
using spatie laravel permissions.
I have maybe altered something while dealing with permissions that could have altered the guard. I have no idea what since I can't see any git changes, maybe via the DB?
At first I tried to tinker and give a specific user admin privileges with:
$role = Spatie\Permission\Models\Role::where('name', 'admin')->get()->first();
When that returned undefined, I checked Auth::guard('admin'), that returns undefined, so I understand that the issue has nothing to do with Spatie package.
After looking in a few questions/answers here on stackoverflow, one of them being config:clear and config:cache, which didn't work and still getting undefined for Auth guard admin.
Any other options I could take to get Auth admin?
thanks
In case you edited your config/auth.php, e.g. to add another guard and your config is cached, your guards may not be reloaded. If you experience this problem, clearing the config will fix it.
https://github.com/laravel/laravel/blob/v5.2.0/config/auth.php
php artisan config:clear OR php artisan config:cache
I'm using Laravel 5.4.
Add admin or administrator to the auth guards. After this php artisan config:clear can be run to remove the previous cached configurations. It should match your roles->name in the database.
\config\auth.php (file)
'guards' => [
...
'administrator' => [
'driver' => 'session',
'provider' => 'users',
],
],
An old question, but stil valid from Laravel 5 to 7

Laravel keeps using hello#example.com with changed conf

In mail.php I have changed from fields but I still get mails with demo values. There is no reference to hello#example.com in project, yet I still get this in mail.
'from' => [
'address' => 'do-not-reply#mysite.net',
'name' => 'MySite.net',
],
Does anyone have an idea what might be wrong?
Clear the config cache by running the following Artisan command:
php artisan config:clear
If you are using supervisor, ensure you set the right user in the conf file, otherwise you will see the emails are being sent as hello#example.com.
In my case the user is www-data - I set it up as root before and was getting this issue.

After upgrading laravel 5.1 to 5.2 \App::environment() always returning "production"

I upgraded laravel 5.1 to 5.2, everything looks good.
But when try to access the app environment not getting what expected.
When i dd($_ENV) this is what i get
"APP_ENV" => "vagrant"
"APP_DEBUG" => "true"
"DB_HOST" => "localhost"
But When dd(\App::environment());
"production"
P.S. even I checked in tinker: dd(env('APP_ENV')) gives me "vagrant"
but dd(\App::environment()) gives me "production".
Dont you think it is odd :(
This is wierd :(
Anyone face this problem ??
you missed a step in the upgrade process:
Configuration
Environment Value
Add an env configuration option to your app.php configuration file that looks like the following:
'env' => env('APP_ENV', 'production'),
P.S. You can check the value from the artisan command:
php artisan env
Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work
php artisan config:cache
php artisan config:clear
php artisan cache:clear

Resources