I wants to logs for each events happened in my website. I would like to know what will be the best way to handle this?
I looked at the packages available but it's not in my requirement.
Let say I wants to record every email activity went through the system plus all insert/update/delete performed by the system user.
I saw EventListener but each time I have to fire an event from the controller I would love if is there any way if I just have to write one time code at somewhere so anytime insert/update/delete happened It will be recorded yes plus emails as well.
Help would be most appreciated.
Thank you.
/Providers/AppServiceProvider.php
use Log;
public function boot()
{
DB::listen(function ($event) {
Log::info('Running SQL query: '.$event->sql);
});
//...
}
That will push an info entry on every query that's executed on the website. Have a look at the docs for specific information on the Log levels.