PHPackages                             spatie/laravel-log-dumper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. spatie/laravel-log-dumper

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

spatie/laravel-log-dumper
=========================

A function to dump anything to the log

1.7.0(4mo ago)121624.6k↓35.3%104MITPHPPHP ^8.0CI passing

Since Apr 2Pushed 4mo ago4 watchersCompare

[ Source](https://github.com/spatie/laravel-log-dumper)[ Packagist](https://packagist.org/packages/spatie/laravel-log-dumper)[ Docs](https://github.com/spatie/laravel-log-dumper)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-log-dumper/feed)WikiDiscussions main Synced 4d ago

READMEChangelog (10)Dependencies (5)Versions (17)Used By (4)

A function to dump anything to the log
======================================

[](#a-function-to-dump-anything-to-the-log)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a262a5a48e4a5c1485097f86260498a8f323e686717c0d62f2b7015a3e58c3b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6c6f672d64756d7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-log-dumper)[![run-tests](https://github.com/spatie/laravel-log-dumper/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-log-dumper/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/89c058177efaa01e969826de9197cc343768ca7de0ee05f9744ec5f170ad6061/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6c6f672d64756d7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-log-dumper)

This package contains a function `ld`. Any argument you pass to it will be dumped to the log. You can pass any kind of value to it.

```
ld('a string', ['an array'], new Class());
```

Under the hood, Symfony's `VarDumper` is used to create string representations.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/756e5d6ae7c90f3561f4192deaee0c4299cf53d7ec6f37b2dff15ae78adec016/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6c6f672d64756d7065722e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-log-dumper)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-log-dumper
```

Usage
-----

[](#usage)

You can pass any variable you want to `ld`.

```
ld('a string', ['an array'], new Class());
```

All arguments will be converted to strings and will be written to the application log using the `info` level.

Using other log levels
----------------------

[](#using-other-log-levels)

If you want to use another log level, you can just call the method you want on `ld`. You can pass these methods any type of argument and any number of arguments. They will all be logged.

```
// logs using the `error` level
ld()->error('a string', ['an array'], new Class())
```

Of course, you can mix and chain different levels.

```
ld()
   ->debug('Debug info', ['an array'])
   ->error('Error info', new Class);
```

Enabling and disabling logging
------------------------------

[](#enabling-and-disabling-logging)

You can disable logging by calling `disable`.

```
ld('foo'); // will be logged

ld()->disable();

ld('bar'); // will not be logged

ld()->enable();

ld('baz'); // will be logged
```

You can pass a boolean to `enable`. This can be handy when you want to log only one iteration of a loop.

```
foreach (range(1, 3) as $i) {
   // only things in the third iteration will be logged
   ld()->enable($i === 3);

   ld('we are in the third iteration');
}
```

Logging queries
---------------

[](#logging-queries)

You can log all queries with `logQueries`.

```
ld()->logQueries(); // all queries after this call will be logged
```

If you wish to stop logging queries, call `stopLoggingQueries`.

```
ld()->stopLoggingQueries(); // all queries after this call will not be logged anymore
```

Alternatively to manually starting and stopping listening for queries, you can also pass a closure to `logQueries`. Only the queries executed inside the closure will be logged.

```
ld()->logQueries(function() {
    $this->mailAllUsers(); // all queries executed in this closure will be logged
});

User::get(); // this query will not be logged
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity53

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 65% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~153 days

Recently: every ~374 days

Total

15

Last Release

133d ago

Major Versions

0.0.3 → 1.0.02020-04-07

PHP version history (3 changes)0.0.1PHP ^7.4

1.4.0PHP ^7.4|^8.0

1.6.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (65 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (9 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (8 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![timvandijck](https://avatars.githubusercontent.com/u/4528796?v=4)](https://github.com/timvandijck "timvandijck (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (3 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (3 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (1 commits)")[![nowendwell](https://avatars.githubusercontent.com/u/5315824?v=4)](https://github.com/nowendwell "nowendwell (1 commits)")[![stephandesouza](https://avatars.githubusercontent.com/u/159077?v=4)](https://github.com/stephandesouza "stephandesouza (1 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")

---

Tags

developmentdumplaravellogspatielaravel-log-dumper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spatie-laravel-log-dumper/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-log-dumper/health.svg)](https://phpackages.com/packages/spatie-laravel-log-dumper)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
