Laravel has an easy-to-use logging system that is saved as a txt log file. But that is also the drawback of text files. It is quite difficult for developers to read, search for errors, necessary information. LogViewer solves these problems, turning the text log file into a vivid, intuitive user interface
Log file before using LogViewer
After using LogViewer have interface
Install LogViewer
Run command
1 2 | composer require arcanedev/log-viewer:~4.7.0 |
Configuration
For laravel> 5.5
- Edit the environment file
.env
LOG_CHANNEL=daily
- Publish logviewer configuration with command:
php artisan log-viewer:publish
With laravel <= 5.5
- Edit
APP_LOG=daily
in the .env file - Add code line
ArcanedevLogViewerLogViewerServiceProvider::class,
to arrayproviders
inconfig/app.php
- And finally run the command to publish the logviwer configuration:
php artisan log-viewer:publish
Run Logviewer
To view log laravel with Logviewer, you access via the link: http: // yourrooturl / log-viewer (ex: http://127.0.0.1:8000/log-viewer ). We will see the Logviewer interface below
Logviewer has many categories from high to low:
- Emergency
- Alert
- Critical
- Warning
- Notice
- Info
- Debug
Try creating some examples for these types of logs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | use IlluminateSupportFacadesLog; . . . public function index() { Log::alert("This is a new Alert!"); Log::critical("This is a critical error message"); Log::debug("This is a debug message"); Log::emergency("There is an emergency! Help!?!?!?!"); Log::error("Houston, we have an error"); Log::info("An informative message"); Log::notice("Notice!"); Log::warning("Be warned, be very warned"); return view('home.index'); } |
Then reload the index page to let the system log the information. Reload Logviewer we get the results
As you can see, Logviewer is very useful, not only for developers but also for testers to make it easier to ensure the quality of the project.