I want to learn more about and how to develop with Vue.js, so I figured some kind of admin/statistics/utility project for Laravel might be a good subject to play around with. I was thinking something that can display and flush/delete Cache, Session, View and Log information.
I initially looked into parsing the log-files when it came to Log Viewing, this is what other packages seem to be doing as well. However I was also interested in a "live stream" update of the Log, no page refresh. It's not impossible to continuously scan a log text file in php in a forever running loop, however I don't feel its really ideal. Considering the log file contains entire stack-traces one log event can be 100's of lines of text.
Laravel 5.6 and the extended Log handling.
While I was updating to 5.6 to test my little project up against my portfolio (where this blog lives actually), I found a new change in Laravel: extended log handling config in the config/logging.php file. This means it is relatively easy to build a custom Log Handler to extend upon all the built in Log functionality. There are already packages out there for Laravel where you could log to a database but since this was not possible until v5.6, most of these seem to really on external custom logic and not really extending upon native Laravel/monolog.
I added a custom Log driver, and quickly realized that this could be a handy little stand-alone package to Laravel. Who knows, maybe it proves useful to someone else as well? Works with all supported SQL databases in Laravel in addition to MongoDB as well.
Checkout the result here: https://github.com/danielme85/laravel-log-to-db
Share this by url