PHPackages                             x-slasher/laravel-mongodb-activity-log - 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. x-slasher/laravel-mongodb-activity-log

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

x-slasher/laravel-mongodb-activity-log
======================================

A very simple activity logger to monitor the users of your website or application and save the data to mongodb

01.1kPHP

Since Aug 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/x-slasher/laravel-mongodb-activity-log)[ Packagist](https://packagist.org/packages/x-slasher/laravel-mongodb-activity-log)[ RSS](/packages/x-slasher-laravel-mongodb-activity-log/feed)WikiDiscussions main Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

[![Social Card of Laravel Activity Log](/art/socialcard.png)](/art/socialcard.png)

Log activity inside your Laravel app
====================================

[](#log-activity-inside-your-laravel-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b101fa363a4770f9539c7ebc6eeee59e1524bfbc83cf89808020ac8d23ac9ac7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d61637469766974796c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-activitylog)[![GitHub Workflow Status](https://camo.githubusercontent.com/082636f62dcd5d12e52ebac7fa312c51f05121eb42ba4bac25789ac11aed7983/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d61637469766974796c6f672f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/laravel-activitylog/actions/workflows/run-tests.yml)[![Check & fix styling](https://github.com/spatie/laravel-activitylog/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/spatie/laravel-activitylog/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/f0e5e9f5f0147bcc0ace895cd3b706de0b98c5349ff59a221fb8b6a5914da207/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d61637469766974796c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-activitylog)

The `spatie/laravel-activitylog` package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. The Package stores all activity in the `activity_log` table.

Here's a demo of how you can use it:

```
activity()->log('Look, I logged something');
```

You can retrieve all activity using the `Spatie\Activitylog\Models\Activity` model.

```
Activity::all();
```

Here's a more advanced example:

```
activity()
   ->performedOn($anEloquentModel)
   ->causedBy($user)
   ->withProperties(['customProperty' => 'customValue'])
   ->log('Look, I logged something');

$lastLoggedActivity = Activity::all()->last();

$lastLoggedActivity->subject; //returns an instance of an eloquent model
$lastLoggedActivity->causer; //returns an instance of your user model
$lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue'
$lastLoggedActivity->description; //returns 'Look, I logged something'
```

Here's an example on [event logging](https://spatie.be/docs/laravel-activitylog/advanced-usage/logging-model-events).

```
$newsItem->name = 'updated name';
$newsItem->save();

//updating the newsItem will cause the logging of an activity
$activity = Activity::all()->last();

$activity->description; //returns 'updated'
$activity->subject; //returns the instance of NewsItem that was saved
```

Calling `$activity->changes()` will return this array:

```
[
   'attributes' => [
        'name' => 'updated name',
        'text' => 'Lorum',
    ],
    'old' => [
        'name' => 'original name',
        'text' => 'Lorum',
    ],
];
```

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

[](#support-us)

[![](https://camo.githubusercontent.com/19b9c0aea98f4ae491bd37519eaa696f32d04f9b649f53ab3764ed4f8ae1cd81/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d61637469766974796c6f672e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-activitylog)

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).

Documentation
-------------

[](#documentation)

You'll find the documentation on .

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the activity log? Feel free to [create an issue on GitHub](https://github.com/spatie/laravel-activitylog/issues), we'll try to address it as soon as possible.

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

[](#installation)

You can install the package via composer:

```
composer require x-slasher/laravel-mongodb-activity-log
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
```

*Note*: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject\_id and causer\_id fields in the published migration before continuing.

After publishing the migration you can create the `activity_log` table by running the migrations:

```
php artisan migrate
```

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-config"
```

also set `ACTIVITY_LOGGER_DB_CONNECTION` value in the env file as the name of mongodb database connection name and

```
ACTIVITY_LOGGER_DB_CONNECTION = mongodb  //or the name of your mongodb connection name in config\database.php file
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

Upgrading
---------

[](#upgrading)

Please see [UPGRADING](UPGRADING.md) for details.

Testing
-------

[](#testing)

```
composer test
```

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)
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](../../contributors)

And a special thanks to [Caneco](https://twitter.com/caneco) for the logo and [Ahmed Nagi](https://github.com/nagi1) for all the work he put in `v4`.

License
-------

[](#license)

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

###  Health Score

18

—

LowBetter than 7% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/04a22c91acabc09e5f8e27e0337ff2c3848cf53da238c22493ca61f1af2c44bc?d=identicon)[x-slasher](/maintainers/x-slasher)

---

Top Contributors

[![x-slasher](https://avatars.githubusercontent.com/u/17163242?v=4)](https://github.com/x-slasher "x-slasher (14 commits)")

### Embed Badge

![Health badge](/badges/x-slasher-laravel-mongodb-activity-log/health.svg)

```
[![Health](https://phpackages.com/badges/x-slasher-laravel-mongodb-activity-log/health.svg)](https://phpackages.com/packages/x-slasher-laravel-mongodb-activity-log)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B12.8k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

2044.7M351](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2430.8M434](/packages/open-telemetry-sdk)

PHPackages © 2026

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