ofuenzalida/laravel-mongodb-log is a Laravel package for mongodb logging for laravel.
It currently has 0 GitHub stars and 24 downloads on Packagist.
Install it with composer require ofuenzalida/laravel-mongodb-log.
Discover more Laravel packages by ofuenzalida
or browse all Laravel packages to compare alternatives.
Last updated
Mongodb Logging-Channel For Laravel Framework
This package is developed as a mongodb logging-channel for Laravel 5.8 and above.
You could use Composer to install the package and all needed dependencies.
composer require ofuenzalida/laravel-mongodb-log
Updating Database Configuration file
You should update your config/database.php file to add a mongodb connection.
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGODB_HOST', 'localhost'),
'port' => env('MONGODB_PORT', 27017),
'database' => env('MONGODB_DATABASE', 'logs'),
],
And also update your config/logging.php to add your custom log-channel.
'channels' => [
'custom' => [
'driver' => 'custom',
'via' => Ofuenzalida\LaravelMongodbLog\LogHandler::class,
],
],
There is a config file to publish which you can use to set database connection and a collection name for your mongodb logs. First publish the config file:
php artisan vendor:publish --provider="Ofuenzalida\LaravelMongodbLog\LogServiceProvider" --tag="config"
Then updating the config file with your desired settings:
<?php
return [
'connection' => env('MONGODB_CONNECTION' ,'mongodb'),
'collection' => env('MONGODB_LOG_COLLECTION' ,'logs'),
];
As mentioned above, the package is a logging channel so you can do logging as before like in the Laravel documentation described.
Logs are saved as Jenssegers\Mongodb\Eloquent\Model instances. You can query them easily. For more information check the Laravel MongoDB Documentation.
to be added ...