{"id":13563596,"url":"https://github.com/danielme85/laravel-log-to-db","last_synced_at":"2025-05-15T11:09:02.240Z","repository":{"id":46729078,"uuid":"145064955","full_name":"danielme85/laravel-log-to-db","owner":"danielme85","description":"Custom Laravel and Lumen 5.6+ Log channel handler that can store log events to SQL or MongoDB databases.  Uses Laravel/Monolog native logging functionality.","archived":false,"fork":false,"pushed_at":"2025-03-04T20:52:23.000Z","size":2654,"stargazers_count":138,"open_issues_count":0,"forks_count":29,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T19:59:01.871Z","etag":null,"topics":["database","db","laravel","laravel-log","log","log-handler","logging","mongodb","mysql","sql"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielme85.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-17T03:02:20.000Z","updated_at":"2025-03-04T17:40:41.000Z","dependencies_parsed_at":"2024-01-14T03:47:19.932Z","dependency_job_id":"3593d40a-12ea-49de-b7d3-676067edccf7","html_url":"https://github.com/danielme85/laravel-log-to-db","commit_stats":{"total_commits":151,"total_committers":12,"mean_commits":"12.583333333333334","dds":"0.39072847682119205","last_synced_commit":"650b148dec19d0300e2044a9c5fc3147b1b8fd5c"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-log-to-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-log-to-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-log-to-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielme85%2Flaravel-log-to-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielme85","download_url":"https://codeload.github.com/danielme85/laravel-log-to-db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","db","laravel","laravel-log","log","log-handler","logging","mongodb","mysql","sql"],"created_at":"2024-08-01T13:01:21.186Z","updated_at":"2025-05-15T11:09:02.219Z","avatar_url":"https://github.com/danielme85.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Laravel Log-to-DB\n[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/danielme85/laravel-log-to-db)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/danielme85/laravel-log-to-db.svg?style=flat-square)](https://packagist.org/packages/danielme85/laravel-log-to-db)\n[![GitHub release](https://img.shields.io/github/release/danielme85/laravel-log-to-db.svg?style=flat-square)](https://packagist.org/packages/danielme85/laravel-log-to-db)\n[![GitHub tag](https://img.shields.io/github/tag/danielme85/laravel-log-to-db.svg?style=flat-square)](https://github.com/danielme85/laravel-log-to-db)\n[![Codecov](https://img.shields.io/codecov/c/github/danielme85/laravel-log-to-db.svg?style=flat-square)](https://codecov.io/gh/danielme85/laravel-log-to-db)\n[![CodeFactor](https://img.shields.io/codefactor/grade/github/danielme85/laravel-log-to-db?style=flat-square)](https://www.codefactor.io/repository/github/danielme85/laravel-log-to-db)\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/danielme85/laravel-log-to-db/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/danielme85/laravel-log-to-db/tree/main)\n\nHi, this is a custom Laravel 5.6+ Log channel handler that can store log events to SQL or MongoDB databases. \nUses Laravel native logging functionality trough [Monolog](https://github.com/Seldaek/monolog).\n\n* [Installation](#installation)\n* [Configuration](#configuration)\n* [Usage](#usage)\n* [Fetching Logs](#fetching-logs)\n* [Custom Eloquent Model](#custom-eloquent-model)\n* [Log Cleanup](#log-cleanup)\n* [Processors](#processors)\n* [Lumen Installation](#lumen-installation)\n* [Local Testing With Docker](#local-testing-with-docker)\n\n\n\u003e :warning: For Laravel version 10 and beyond, please use version 4 or later of this package. \n\u003e \u003cbr\u003e For Laravel version 5.6 to 9, please use version 3.x.x.\n\n## Installation\nUse the composer require or add to composer.json. \n```\ncomposer require danielme85/laravel-log-to-db\n```\n\nIf you are using SQL database server to store log events you can use the migration included. The MongoDB driver does not require the migration.\nCopy the migration file for log the database table to your app (you can also do any changes you want or manually copy this file your database/migrations folder).\n```\nphp artisan vendor:publish --tag=migrations --provider=\"danielme85\\LaravelLogToDB\\ServiceProvider\"\n```\nRun the Laravel migration artisan command.\n```\nphp artisan migrate\n```\n\n\n\u003ci\u003eFor optional MongoDB support you need to install jenseegers/mongodb addon to Laravel\u003c/i\u003e\n```\n#Optional mongodb support, not required!\n\ncomposer require jenssegers/mongodb\n```\n\n## Configuration\nStarting with Laravel 5.6 and later, you will have a new config file: \"config/logging.php\". \nYou will need to add an array under 'channels' for Log-to-DB here like so:\n```php \n'database' =\u003e [\n    'driver' =\u003e 'custom',\n    'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class\n    ...\n    ],\n```\nThese are the minimum required logging.php config settings to get started. Please note that the array index 'database' \ncan be whatever string you like as long as it is unique to this logging config. \nYou can also give the logging channel a name that later is referenced in a column in the DB table, this way you can have multiple \nlogging-to-db channels. \n\n```php\n'channels' =\u003e [\n    'stack' =\u003e [\n        'name' =\u003e 'Log Stack',\n        'driver' =\u003e 'stack',\n        'channels' =\u003e ['database', 'other-database', 'file'],\n    ],\n    'database' =\u003e [\n        'driver' =\u003e 'custom',\n        'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class,\n        'name' =\u003e 'Basic DB Logging'\n    ],\n    'other-database' =\u003e [\n        'driver' =\u003e 'custom',\n        'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class,\n        //'model' =\u003e App\\Model\\Log::class, //Your own optional custom model\n        'level' =\u003e env('APP_LOG_LEVEL', 'debug'),\n        'name' =\u003e 'My DB Log with a bunch more settings',\n        'connection' =\u003e 'default',\n        'collection' =\u003e 'log',\n        'detailed' =\u003e true,\n        'queue' =\u003e false,\n        'queue_name' =\u003e '',\n        'queue_connection' =\u003e '',\n        'max_records' =\u003e false,\n        'max_hours' =\u003e false,\n        'processors' =\u003e [\n              //Monolog\\Processor\\HostnameProcessor::class\n              // ..\n         ]\n    ],\n    ...\n]\n```\n * driver = Required to trigger the log driver.\n * via = The Log handler class.\n * level = The minimum error level to trigger this Log Channel.\n * name = The channel name that will be stored with the Log event. Please note that if you use the stack driver the name value in the stack array is used.\n * connection = The DB connection from config/database.php to use (default: 'default').\n * collection = The DB table or collection name. (Default: log).\n * detailed = Store detailed log on Exceptions like stack-trace (default: true).\n * processors = Array of additional processors. These will add additional info into the 'extra' field in the logged data.\n[More information about processors](#processors)\n \nMore info about some of these options: https://laravel.com/docs/9.x/logging#customizing-monolog-for-channels\n\nThere are some default settings and more information about configuring the logger in the 'logtodb.php' config file.\nThis could be copied to your project if you would like edit it with the vendor publish command.\n```\nphp artisan vendor:publish --tag=config --provider=\"danielme85\\LaravelLogToDB\\ServiceProvider\"\n```\nYou can also change these settings in your env file.\n```\nLOG_DB_CONNECTION='default'\nLOG_DB_DETAILED=false\nLOG_DB_MAX=100\nLOG_DB_QUEUE=false\nLOG_DB_QUEUE_NAME='logToDBQueue'\nLOG_DB_QUEUE_CONNECTION='default'\nLOG_DB_MAX_COUNT=false\nLOG_DB_MAX_HOURS=false\nLOG_DB_DATETIME_FORMAT='Y-m-d H:i:s:ms'\n```\n\n\u003e **PLEASE NOTE**: Starting with v2.2.0, the datetime column will be saved as a string in the format given in\n\u003e 'datetime_format' in logtodb.php config file, or the LOG_DB_DATETIME_FORMAT value in your .env file.\n\n#### Config priority order\nThere are three places you can change different options when using log-to-db: \n1. The config file: config/logtodb.php (after doing vendor:publish).\n2. Your .env file will override settings in the logtodb.php config file.\n3. The Laravel logging config file: config/logging.php. You need to add a custom array here as mentioned above, \nin this same array you can specify/override config settings specifically for that log channel.\n\nConfig values set in point 1 \u0026 2 would work as default for all new log channels you add in the \"channels\" array for the \nLaravel logging configuration (config/logging.php).\n\n#### Log Worker Queue\nIt might be a good idea to save the log events with a Queue Worker. This way your server does not have to wait for\nthe save process to finish. You would have to configure the Laravel Queue settings and run the Queue listener. \nhttps://laravel.com/docs/6.x/queues#running-the-queue-worker\n\nThe queue can be enabled/disabled in any of the following places:  \n* LOG_DB_QUEUE = true | in .env\n* queue_db_saves =\u003e true | in config/logtodb.php\n* queue =\u003e true | in the log channel config array -\u003e config/logging.php\n\n## Usage\nSince this is a custom log channel for Laravel, all \"standard\" ways of generating log events etc should work with \nthe Laravel Log Facade. See https://laravel.com/docs/6.x/logging for more information.\n```php\nLog::debug(\"This is an test DEBUG log event\");\nLog::info(\"This is an test INFO log event\");\nLog::notice(\"This is an test NOTICE log event\");\nLog::warning(\"This is an test WARNING log event\");\nLog::error(\"This is an test ERROR log event\");\nLog::critical(\"This is an test CRITICAL log event\");\nLog::alert(\"This is an test ALERT log event\");\nLog::emergency(\"This is an test EMERGENCY log event\");\n```\nYou can also log to specific log channels:\nLog::channel('database')debug(\"This is an test DEBUG log event\");\n\n\n## Fetching Logs\nThe logging by this channel is done trough the Eloquent Model builder.\nLogToDB::model($channel, $connection, $collection);\nYou can skip all function variables and the default settings from the config/logtodb.php will be used.\n```php\n$model = LogToDB::model();\n$model-\u003eget(); //All logs for default channel/connection\n```\n\nSome more examples of getting logs\n```php\n$logs = LogToDB::model()-\u003eget();\n$logs = LogToDB::model()-\u003ewhere('level_name', '=', 'INFO')-\u003eget();\n```\n\nWhen getting logs for specific channel or DB connection and collection you can either use the channel name matching \nconfig/logging.php or connection name from config/databases.php. You can also specify collection/table name if needed as \nthe third function variable when fetching the model.  \n```php\n$logsFromDefault = LogDB::model()-\u003eget(); //Get the logs from the default log channel and default connection.\n$logsFromChannel = LogDB::model('database')-\u003eget(); //Get logs from the 'database' log channel.\n$logsFromChannel = LogDB::model('customname')-\u003eget(); //Get logs from the 'customname' log channel.\n$logsFromMysql   = LogToDB::model(null, 'mysql')-\u003eget(); //Get all logs from the mysql connection (from Laravel database config)\n$logsFromMongoDB = LogToDB::model(null, 'mongodb')-\u003eget(); //Get all logs from the mongodb connection (from Laravel database config)\n$logsFromMysqlTable  = LogToDB::model(null, 'mysql', 'table')-\u003eget(); //Get all logs from the mysql table: 'table'\n```\n\n## Custom Eloquent Model\nSince Laravel is supposed to use static defined collection/table names, \nit might be better to use your own model in your app for a more solid approach.\nYou can use your own eloquent model by referencing it in the config, then adding the trait: \"LogToDbCreateObject\"\n\n##### SQL\n```php\nnamespace App\\Models;\n\nuse danielme85\\LaravelLogToDB\\Models\\LogToDbCreateObject;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass CustomLog extends Model\n{\n    use LogToDbCreateObject;\n\n    protected $table = 'log';\n    protected $connection = 'mysql';\n    \n}\n```\n\n##### MongoDB\n```php\nnamespace App\\Models;\nuse danielme85\\LaravelLogToDB\\Models\\LogToDbCreateObject;\nuse Jenssegers\\Mongodb\\Eloquent\\Model as Eloquent;\n\nclass CustomLogMongo extends Eloquent\n{\n    use LogToDbCreateObject;\n\n    protected $collection = 'log';\n    protected $connection = 'mongodb';\n\n}\n``` \n\nLOG_DB_MODEL='App\\Models\\CustomLog'\n\n\u003e **WARNING**: Fetching the model trough the dynamic Eloquent model (default behavior) have some side-effects as tables and connections are \n              declared dynamically instead of assigned properties in the model class. Certain functions are broken like LogToDB::model-\u003eall(), while LogToDB::model-\u003ewhere()-\u003eget() will work as normal.\n\u003e             Using your own models avoids these problems.\n\n#### Model Closures and Observers\nYou can either add [closures](https://laravel.com/docs/7.x/eloquent#events-using-closures) on your custom application model mentioned above, \nor add a [model observer](https://laravel.com/docs/7.x/eloquent#observers) for the default LogToDb models.\n\u003cbr\u003e\nCreate a observer:\n```\n\u003c?php\nnamespace App\\Observers;\n\nuse danielme85\\LaravelLogToDB\\Models\\DBLog;\n\nclass LogObserver\n{\n    public function created(DBLog $log)\n    {\n        //\n    }\n}\n```\nThen add to your AppServiceProvider (or another provider that calls the app boot function).\n```\n   namespace App\\Providers;\n   \n   use App\\Observers\\LogObserver;\n   use danielme85\\LaravelLogToDB\\LogToDB;\n   use Illuminate\\Support\\ServiceProvider;\n   \n   class AppServiceProvider extends ServiceProvider\n   {\n       public function boot()\n       {\n           LogToDB::model()-\u003eobserve(LogObserver::class);\n       }\n   }\n```\n\n\n#### Adding tables/expanding collections \nThe Log handler for SQL expects the following schema:\n```php\nSchema::create('log', function (Blueprint $table) {\n      $table-\u003eincrements('id');\n      $table-\u003etext('message')-\u003enullable();\n      $table-\u003estring('channel')-\u003enullable();\n      $table-\u003einteger('level')-\u003edefault(0);\n      $table-\u003estring('level_name', 20);\n      $table-\u003einteger('unix_time');\n      $table-\u003etext('datetime')-\u003enullable();\n      $table-\u003elongText('context')-\u003enullable();\n      $table-\u003etext('extra')-\u003enullable();\n      $table-\u003etimestamps();\n });\n```\nThis is the migration that ships with this plugin. You can add as many tables as you want, and reference them in the 'collection' config value. \nCollection = table, I used the term collection as it works for both SQL/noSQL. \nNo migrations needed for MongoDB.\n\nNo indexes are added per default, so if you fetch a lot of log results based on specific time ranges or types: it might be a good idea to add some indexes. \n \n## Log Cleanup\nThere are config values that you can set to specify the max number of log records to keep, or the max record age in hours.\n\n* logging.php channel array -\u003e (max_records, max_hours).\n* .env file -\u003e (LOG_DB_MAX_COUNT, LOG_DB_MAX_HOURS).\n\n\u003cb\u003eThese option is set to *false* per default, these have to be set to desired integers before you can run the \"log:delete\" artisan command.\u003c/b\u003e \n```\nphp artisan log:delete\n```\nThis command will delete records based on settings described above. Add this command to your Console/kernel.php, or run manually in cron etc to enable automatic cleanup.\n\n#### Manual Cleanup\nThere is a helper function to remove the oldest log events and keep a specified number\n```php\nLogToDB::removeOldestIfMoreThan(100);\n```\nOr based on date (most be valid date/datetime supported by strtotime())\nhttp://php.net/manual/en/function.strtotime.php\n\n```php\nLogToDB::model()-\u003eremoveOlderThan('2019-01-01');\nLogToDB::model()-\u003eremoveOlderThan('2019-01-01 23:00:00');\n```\n\n## Processors\nMonolog ships with a set of [processors](https://github.com/Seldaek/monolog/tree/master/src/Monolog/Processor), these will generate additional data and populate the 'extra' field.\nI've also added a couple of example processors in this pacage under src/Processors.\nTo enable processors you can add them to the log config array:\n```php\n'database' =\u003e [\n    'driver' =\u003e 'custom',\n    'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class\n    ...\n    'processors' =\u003e [\n        \\danielme85\\LaravelLogToDB\\Processors\\PhpVersionProcessor::class,\n        Monolog\\Processor\\HostnameProcessor::class,\n    ]\n\n```\n\nYou could also create your own custom processor, make sure they implement [Monolog\\Processor\\ProcessorInterface](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Processor/ProcessorInterface.php).\n\n##### Example of custom processor\n```php\n\u003c?php\n\nnamespace App\\CustomProcessors;\n\nuse Monolog\\Processor\\ProcessorInterface;\n\nclass PhpVersionProcessor implements ProcessorInterface {\n     /**\n     * @return array The processed record\n     */\n     public function __invoke(array $record) {\n         $record['extra']['php_version'] = phpversion();\n         \n         return $record;\n     }\n}\n\n```\n\n## More logging.php config examples\n```php\n'default' =\u003e env('LOG_CHANNEL', 'stack'),\n\n'channels' =\u003e [\n    'stack' =\u003e [\n        'driver' =\u003e 'stack',\n        'channels' =\u003e ['database', 'mongodb', 'single'],\n    ],\n    \n    'database' =\u003e [\n        'driver' =\u003e 'custom',\n        'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class,\n        'level' =\u003e env('APP_LOG_LEVEL', 'debug'),\n        'connection' =\u003e 'default',\n        'collection' =\u003e 'log'\n        'detailed' =\u003e true,\n        'queue' =\u003e true\n        'queue_name' =\u003e 'logQueue'\n        'queue_connection' =\u003e 'redis',\n        'max_records' =\u003e 1000,\n        'max_hours' =\u003e 24,\n    ],\n    \n    'mongodb' =\u003e [\n        'driver' =\u003e 'custom',\n        'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class,\n        'level' =\u003e 'debug',\n        'connection' =\u003e 'mongodb',\n        'collection' =\u003e 'log',\n        'detailed' =\u003e true,\n        'queue' =\u003e true\n        'queue_name' =\u003e 'logQueue'\n        'queue_connection' =\u003e 'redis'\n    ],\n    \n    'limited' =\u003e [\n        'driver' =\u003e 'custom',\n        'via' =\u003e danielme85\\LaravelLogToDB\\LogToDbHandler::class,\n        'level' =\u003e 'warning',\n        'detailed' =\u003e false,\n        'max_rows' =\u003e 10,\n        'name' =\u003e 'limited',\n    ]\n    \n    'single' =\u003e [\n        'driver' =\u003e 'single',\n        'path' =\u003e storage_path('logs/laravel.log'),\n        'level' =\u003e env('APP_LOG_LEVEL', 'debug'),\n    ],\n    //....\n]\n```\n\n## Lumen Installation\n\n* Create a config folder in your projects root directory (if you don't already have one), then add a logging.php config file there.\nUse the [Laravel logging.php](https://github.com/laravel/laravel/blob/master/config/logging.php) config file as an example/starting point.\nYou can also add all the other \"missing\" config files from the Laravel config folder to your Lumen project. \n\n* To use these config files you have to load them in your applications bootstrap/app.php file (or add your own service provider file and load it in that same file).\n\nYou also need to make sure that all the needed basic config values for logtodb is set by either: \n* Copy over logtodb.php from the config folder of this addon,\n* or just add all your log-to-db options in your applications config/logging.php file (probably easiest). Just follow the \nconfiguration example above under the [configuration](#configuration) section.\n  \nSince we are using Lumen we need to specify the config and service providers in the \"bootstrap/app.php\" file.\n\n```\n/*\n|--------------------------------------------------------------------------\n| Register Config Files\n|--------------------------------------------------------------------------\n|\n| Now we will register the \"app\" configuration file. If the file exists in\n| your configuration directory it will be loaded; otherwise, we'll load\n| the default version. You may register other files below as needed.\n|\n*/\n\n$app-\u003econfigure('app');\n//$app-\u003econfigure('logtodb'); //if you copied over and want to use the base config from logtodb.\n$app-\u003econfigure('logging');\n\n```\n\nNext step is to register the service provider, either in bootstrap/app.php or in app/Provider/AppServiceProvider.\n```\n/*\n|--------------------------------------------------------------------------\n| Register Service Providers\n|--------------------------------------------------------------------------\n|\n| Here we will register all of the application's service providers which\n| are used to bind services into the container. Service providers are\n| totally optional, so you are not required to uncomment this line.\n|\n*/\n\n// $app-\u003eregister(App\\Providers\\AppServiceProvider::class);\n// $app-\u003eregister(App\\Providers\\AuthServiceProvider::class);\n// $app-\u003eregister(App\\Providers\\EventServiceProvider::class);\n$app-\u003eregister(\\danielme85\\LaravelLogToDB\\ServiceProvider::class);\n```\n\nAfter adding the service provider you should be able to run the database migration in Lumen with:\n```\nphp artisan migrate --path=vendor/danielme85/laravel-log-to-db/src/migrations/2018_08_11_003343_create_log_table.php\n```\nPlease note that you need a working db connection in Lumen at this point.\n\nAnd then maybe it works... ¯\\_(ツ)_/¯\n\n#### Using worker queue to write log to db with Lumen\nYou would need to set up a queue driver in Lumen before you can use the queue (default is: QUEUE_CONNECTION=sync, which is basically no queue).\nMore info about the [queues in Lumen doc](https://lumen.laravel.com/docs/7.x/queues) (they are mostly the same as Laravel). \nI would recommend the Redis queue driver but database should also work.\n\n#### How to make Redis work in Lumen (in general).\ninstall per command\n```\n composer require predis/predis\n composer require illuminate/redis\n```\n\nOR add to composer.json\n```\n...\n  \"require\": {\n        \"predis/predis\": \"~1.0\",\n        \"illuminate/redis\": \"5.0.*\",\n...\n```\nOr install other alternatives to predis. \n\nAdd service provider and enable eloquent in your bootstrap/app.php file (Eloquent only needed if you use the model/model helper class to fetch new log event);\n```\n\n$app-\u003ewithFacades();\n$app-\u003ewithEloquent();\n\n$app-\u003eregister(Illuminate\\Redis\\RedisServiceProvider::class);\nif (!class_exists('Redis')) {\n    class_alias('Illuminate\\Support\\Facades\\Redis', 'Redis');\n}\n```\n\nNow you can set your .env values to use Redis for the queue and cache if you so please:\n```\nREDIS_CLIENT=predis\nQUEUE_CONNECTION=redis\nCACHE_DRIVER=redis\n```  \n\n## Local Testing With Docker\nThere is a helper bash script called 'runLocalTestInDocker.sh', that runs the following docker commands:\n```\ndocker-compose up -d mariadb mongo \u0026\u0026\ndocker-compose up php7 \u0026\u0026\ndocker-compose up php8 \u0026\u0026\ndocker-compose down\n```\nTo run Docker is required, give execute rights to the script and run:\n```\nchmod +x runLocalTestInDocker.sh \u0026\u0026 \n./runLocalTestInDocker.sh\n```\n\n### Development supported by:\n![](https://media.giphy.com/media/3knKct3fGqxhK/giphy.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielme85%2Flaravel-log-to-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielme85%2Flaravel-log-to-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielme85%2Flaravel-log-to-db/lists"}