Log Request & Debug for Laravel

v2.0.0 2018-04-15 14:08 UTC

This package is auto-updated.

Last update: 2021-01-08 16:01:44 UTC


Total Downloads Latest Stable Version License PHP Version


Log Request & Debug for Laravel


Require this package with composer:

composer require songshenzong/log


Publish configuration files. If not, They can not be serialized correctly when you execute the config:cache Artisan command.

php artisan vendor:publish --provider="Songshenzong\Log\ServiceProvider"


If you use a dingo/api route, make sure you load the Middleware in config/api.php.

'middleware' => [

The profiler is enabled in all environment by default, You can override that in the config (songshenzong-log.env).

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Songshenzong\Log\ServiceProvider"

Let's start



You can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency):

Songshenzong::warning('Watch out…');
Songshenzong::addMessage('Another message', 'myLabel');

And start/stop timing:

Songshenzong::startMeasure('render','Time for rendering');
Songshenzong::addMeasure('now', LARAVEL_START, microtime(true));
Songshenzong::measure('My long operation', function() {
    // Do something…

Or log exceptions:

try {
    throw new Exception('foobar');
} catch (Exception $e) {
    songshenzongLog() -> addThrowable($e);

There are also helper functions available for the most common calls:

// All arguments will be dumped as a debug message
debug($var1, $someString, $intValue, $object);

start_measure('render','Time for rendering');
add_measure('now', LARAVEL_START, microtime(true));
measure('My long operation', function() {
    // Do something…

If you want you can add your own DataCollectors, through the Container or the Facade:

songshenzongLog() -> addCollector(new Songshenzong\Log\DataCollector\MessagesCollector('my_messages'));
//Or via the App container:
$songshenzong_log = App::make('SongshenzongLog');
$songshenzong_log->addCollector(new Songshenzong\Log\DataCollector\MessagesCollector('my_messages'));

Note: Not using the auto-inject, will disable the Request information, because that is added After the response. You can add the default_request data collector in the config as alternative.

Enabling/Disabling on run time

You can enable or disable the Songshenzong during run time.

songshenzongLog() -> enable();
songshenzongLog() -> disable();

NB. Once enabled, the collectors are added (and could produce extra overhead), so if you want to use the Songshenzong in production, disable in the config and only enable when needed.


Please refer to our extensive Wiki documentation for more information.


For answers you may not find in the Wiki, avoid posting issues. Feel free to ask for support on Songshenzong.com


This package is licensed under the BSD 3-Clause license.