Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

newlearner2's avatar

how to count Laravel log in a day?

I want to know how I count that how many times a critical error is occurred in a day so I can send to slack only when error occurred first time a day than 10th error a day.

also how to keep log file size to 5 Mb without using logrotate I am on shared hosting that's why I cannot use logrotate ?

Log::channel('slack')->critical('Something happened!');
0 likes
5 replies
Snapey's avatar

Sorry, why can you not set the logfile to daily ?

newlearner2's avatar

what i want to do is this If error occurred first time in that day than send it to slack if error occurred the 10th times in that day than send it to slack if error occurred the 100th times in that day than send it to slack

I don't want to send log each time it occurred because slack has limit per month

Talinon's avatar

@newlearner2 You could consider using Bugsnag. It'll record all your errors and the frequencies, along with a bunch of other useful information.You then have the option of completely ridding yourself of the log file, if you desire. It also has different settings, but by default it'll only notify upon the first occurrence of an error, which is what you're looking for. You can also configure your Bugsnag project to post to Slack.

https://docs.bugsnag.com/platforms/php/laravel/

Please or to participate in this conversation.