When and how do Laravel daily logging files get deleted? - laravel-5

I'm running Laravel 5.8 and using the built-in Laravel Log functionality. And I've created a few custom logs.
I set each of them to store the daily log files for 30 days, like so:
'reconciliation' => [
'driver' => 'daily',
'path' => storage_path('logs/reconciliation/reconciliation.log'),
'days' => 30
]
However, the logs don't stay for 30 days, like I've set them to. They stay for 7.
I've heard that there is another configuration called log_max_files, which might be what I'm looking for.
But all the references to log_max_files are from Laravel 5.4 and below. And I know that the logging functionality was revamped in 5.6. So I'm not sure if log_max_files even works anymore and I'd like to test it.
I've created a new log file with a date far outside the current 7-day range and I want to confirm that it gets deleted when the logs get cleared.
I'm just not sure when Laravel clears out the old logs. I couldn't find any in-depth information like that in the docs and my Google searching hasn't turned anything up.
I've tried restarting my server, running php artisan config:clear and php artisan cache:clear with no luck.
Does anyone actually know the process by which these log files get deleted and when that process runs?

Related

Laravel and Valet bizarre loading issue

Strange problem: Have installed Laravels 'Valet' to serve sites from .dev locally. When I am in my 'code' directory where I parked valet and create say laravel new blog installed perfectly and spins up on blog.dev. However say I create laravel new test and visit test.dev I get 404 - nothing found ...? I removed everything and tried again but the same thing happens. Has anyone else had the same problem?
UPDATE
Interestingly, from that same directory 'code' If i run a ping on blog.dev I get returned packets and pings. However I do the same on test, I get bunch of help commands?
FURTHER UPDATE
So inside the project 'test' if I run php artisan serve I get a response of Laravel development server started: <http://127.0.0.1:8000> and If I visit the path bingo it works. But that confuses the issue even further for me...?
EVEN FUTHER UPDATES
So, I wish to add this iMac was a previous developers so the home folder is called Adam, I am a seperate user but also an Admin with my own folder sat next to it called 'Dan'but not a 'home' directory as such it is just in the sames 'Users' directory whenever I try to do anything I get errors like: ERROR: Notice: Undefined index: domain in /Users/Adam/.composer/vendor/laravel/valet/cli/valet.php on line 55 That was when trying to spin up laravel share

Why Laravel project website response is over 10 seconds long on artisan localhost only?

When I work with my local version of project then every action taken on website needs around 10 seconds long response. It's so frustraiting. And it hapens only on my PC. How can I prevent this action?? Downloading project from VCS to new folder helps for short time. I have Windows 10, Laravel 5.4, PHP 7.0.15. Commands
php artisan cache:clear
and
php artisan optimize
are not helping. Please, can anyone help?
Do you use xdebug? It can slow down application.
Also check your laravel debug option in .env file, it should be:
APP_DEBUG=false
That was laravel.log. I deleted it and everything seems to be ok. The file had 56MB of logs. Now i have to find out how to stop logging or create new log file every 2MB.

Laravel queue job does not work in background

Hy! I have an application where I have to send some emails at certain actions (such as user creation, etc.). Problem is they are not running in the background, instead I have to wait until the process is done, and then it redirects me to another page.
I use database driver with queues, Laravel 5.2.
My code for email, for exp, after user creation:
$this->dispatch(new WelcomeEmail($user));
Artisan::call('queue:work');
where WelcomeEmail is the job that is pushed on queue. This type of code is placed in all the places where I want an email to be send. What is wrong?
First, you do not want to use Artisan::call on 'queue' commands within your dispatcher.
You should open your terminal and execute: php artisan queue:listen --timeout=0 --tries=1 and you should let it be.
Then you can visit your page where $this->dispatch or even better dispatch method will be called. Code on that page should be:
dispatch(new WelcomeEmail($user));
On your production server, you should use supervisord to monitor your php artisan queue:listen command, to make sure that it's up and running all the time.
For further reading please visit: https://laravel.com/docs/5.2/queues
I don't know why changing .env is not enough to fix the issue but after changing this line from
'default' => env('QUEUE_CONNECTION', 'sync'),
to
'default' => env('QUEUE_CONNECTION', 'database'),
in config/queue.php file
Everything works fine.
I had a similar problem, but because was a single job I didn't want a daemon to always run, also there is the update code problem,.... So I solved running the command directly from PHP, like:
exec('nohup php /my_folder/artisan queue:work --once > /dev/null 2>&1 &');
This will launch one job and then turn off, without waiting the result. But be careful on the Laravel log file permissions, the o.s. user can change if you are running under Linux depending on context and configuration.
Hope that can help someone.

Unable to store session in Database in laravel 5.2

I recently upgraded my application from laravel 5.1 to 5.2 version. Also I am trying to store session in Database which is currently stored in file.
I have changed .env file to include SESSION_DRIVER=database. Also I have changed session.config file to include 'driver' => env('SESSION_DRIVER', 'database') and generated required session table.
But when I tried to login to the application I am getting TokenMismatchException in VerifyCsrfToken.php line 67: If I change SESSION_DRIVER=file then application is working as expected.
But this was not the case in Laravel 5.1 version.
What is changed in Laravel 5.2 version and what steps are required to store user session in database?
I had to deal with this issue myself as well. So the initial steps are as you had already mentioned in your question.
On fresh install of laravel and verify that everything works, change the SESSION_DRIVER=file to SESSION_DRIVER=database
Run the following commands IN ORDER in your console within the directory of your app:
php artisan session:table
composer dump-autoload
php artisan migrate
(This step might be different from what you did) In your config\session.php file search for:
'driver' => env('SESSION_DRIVER', 'file'),
and change it to the following
'driver' => env('SESSION_DRIVER', 'app.database'),
Within the same config\session.php file change the encrypt configuration to true
Set your connection and table name settings appropriately
'connection' => 'database_name_here',
'table' => 'sessions', //here you can change but sessions is recommended until you get more comfortable with how it all works
Attempt to login to your application and check your database to see if it all works.
If more help is needed you can also check a few resources that have helped me solve the issue. Keep in mind these resources are of people having similar issues but maybe your problem is similar to theirs. Only way to find out is to investigate. Hope this helps! =) :
https://laracasts.com/discuss/channels/laravel/how-to-store-users-id-in-session-table-laravel-5
https://laravel.com/docs/5.2/session
(Video tutorial on Laravel Sessions, VERY good place to help you get to where you need to be!)
https://www.youtube.com/watch?v=-FMecyZs5Cg
look it's ok to go with it manual but why don't u use the php artisan make:auth
it creates every thing u need for authentication and also helps u keeping the session instead of doing it manual ?

Laravel 5.1 package to Log all events installation: missing log file and nothing written

I'm trying to use a laravel-request-logger.
I followed the installation steps and set the log level to debug.
Then changed the log level to debug
Ran composer update and composer dump-autoload
Tried several good and bad requests
First I didn't even find the file mentioned http.log anywhere in my app folder, neither in my storage folder (where the only logs folder is).
So I created the http.log file myself within the storage\logs folder and gave all users write permissions. But nothing is written after several good and bad requests.
Second, I notice the default laravel.log hasn't logged anything since installing this package, probably because this package overules the default?
Because Laravel’s logging features are managed by Monolog53, you have a wide array of additional logging options at your disposal, including the ability to write log messages to this log file, set logging levels, send log output to the Firebug console54 via FirePHP55, to the Chrome console56 using Chrome Logger57, or even trigger alerts via e-mail, HipChat58 or Slack59.
public function index(){
$items = [
'one',
'two'
];
\Log::debug($items);
return view('about');
}
Aa customized log message similar to the following will
be appended to storage/logs/laravel.log:
[2015-12-14 01:51:56] local.DEBUG:
array ( 0 => 'Pack luggage',
'one',
'two'
)
There is of course more but it will be to difficult to explain it in here. :) Cheers

Resources