Laravel supports Monolog for handling logs. Monolog supports many different handlers, including database handlers like the MongoDB handler.
You can use the MongoDB handler by adding a new channel to the channels
array in your config/logging.php
file, e.g.:
'channels' => [
'mongolog' => [
'driver' => 'monolog',
'handler' => Monolog\Handler\MongoDBHandler::class,
'with' => [
'database' => 'mongo-database-name',
'collection' => 'log-collection-name',
],
],
Then you can set your default log channel to mongolog
in your .env
file, e.g. LOG_CHANNEL=mongolog
.