Professionally viewing Laravel logs is critical for identifying and debugging problems in your application. We can easily check our logs in local environments by saving them to local, but this is a time-consuming process in live environments.
In this section, I'll show you packages that will provide you with a graphical user interface that will allow you to easily check all of our logs, such as errors, warnings, and debug messages. From there, we can also clear / delete our log files. Daily logs are preferable because they make it easier to trace logs.
Let's look at how we can incorporate that package into our existing Laravel application.
Installation
It is recommended to use the _opcodesio _ package for Laravel running on PHP 8 and higher.
To use composer to install the package, type composer require opcodesio/log-viewer
.
After installing the package, run php artisan log-viewer:publish
to publish the front-end assets.
Usage
Once installed, you will be able to access Log Viewer directly from your browser.
By default, the application is available at: {APP_URL}/log-viewer
.
(for example: http://{your-project}/log-viewer
)
It is recommended to use the arcanedev
package for Laravel running on PHP 7 and lower.
You can install this package using Composer by issuing the following command: composer require arcanedev/log-viewer:x.x
, where x.x
is the compatible version for your Laravel version.
composer require arcanedev/log-viewer
for risk takes like me
This for the version you are sure of
composer require arcanedev/log-viewer:~4.7.0
for Laravel 5.8
composer require arcanedev/log-viewer:~4.6.0
for Laravel 5.7
composer require arcanedev/log-viewer:~4.5.0
for Laravel 5.6
composer require arcanedev/log-viewer:~4.4.0
for Laravel 5.5
composer require arcanedev/log-viewer:~4.3.0
for Laravel 5.4
composer require arcanedev/log-viewer:~4.2.0
for Laravel 5 > 5.3
Set this in your .env
file APP_LOG=daily
for Laravel 5.5 and below.
Artisan commands
Run the following command to publish the configuration php artisan log-viewer:publish
DONE!
Go to http://{your-project}/log-viewer
The error join(): Passing glue string after array is deprecated
might appear. If you want to view the log according to the date at http://your-project/log-viewer/logs/2023-07-30
you may receive a 504 Error or a 503 Error, depending on whether the debug mode is enabled in your .env
file.
Fix
Go to your project directory locate resources/views/vendor/log-viewer/bootstrap-4
edit show.blade.php
find join(log_styler()->toHighlight(), '|')
and replace with join('|', log_styler()->toHighlight())
Enjoy the rest of your day as a programmer
Top comments (0)