{"id":17539987,"url":"https://github.com/alkhatibdev/logrotation","last_synced_at":"2025-04-11T20:20:23.242Z","repository":{"id":257823911,"uuid":"871750118","full_name":"alkhatibdev/logrotation","owner":"alkhatibdev","description":"Laravel package for easy log rotation","archived":false,"fork":false,"pushed_at":"2025-04-08T08:25:43.000Z","size":10,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T09:28:14.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/alkhatibdev.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":"2024-10-12T20:37:03.000Z","updated_at":"2025-04-08T08:25:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef50318d-f92b-4823-be5b-b2f5c4d7a2f5","html_url":"https://github.com/alkhatibdev/logrotation","commit_stats":null,"previous_names":["alkhatibdev/logrotation"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flogrotation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flogrotation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flogrotation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkhatibdev%2Flogrotation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkhatibdev","download_url":"https://codeload.github.com/alkhatibdev/logrotation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473079,"owners_count":21109629,"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":[],"created_at":"2024-10-20T22:07:05.830Z","updated_at":"2025-04-11T20:20:23.232Z","avatar_url":"https://github.com/alkhatibdev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Log Rotation Package\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/alkhatibdev/logrotation.svg?style=flat-square)](https://packagist.org/packages/alkhatibdev/logrotation)\n[![Total Downloads](https://img.shields.io/packagist/dt/alkhatibdev/logrotation.svg?style=flat-square)](https://packagist.org/packages/alkhatibdev/logrotation)\n[![GitHub Issues](https://img.shields.io/github/issues/alkhatibdev/logrotation.svg?style=flat-square)](https://github.com/alkhatibdev/logrotation/issues)\n\nThis package makes log file rotation easier by automatically managing and organizing Laravel logs based on file creation date, retaining only the most recent logs (e.g., 6 months) and discarding older logs. This solution is ideal for applications that generate high volumes of logs, providing efficient log management and preventing excessive disk usage over time.\n\n## Benefits\n\n- Rotates your log files based on the log file's current date, ensuring that only the most recent logs are retained.\n- Retain logs for a configurable number of months (default: 6 months), which can easily be modified through the configuration file.\n- Automatically deletes old logs after the configured retention period, freeing up space on your server.\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require alkhatibdev/logrotation\n```\n\n## Configuration\n\nTo publish the configuration file, run the following command:\n\n```bash\nphp artisan vendor:publish --tag=logrotation\n```\n\nThis will create a `logrotation.php` file in your `config/` directory where you can customize the number of months to retain logs:\n\n```php\nreturn [\n    'max_months' =\u003e env('LOG_ROTATION_MAX_MONTHS', 6),\n];\n```\n\n## Usage\n\nOnce installed, you can integrate the log rotation into your application's task scheduling. To rotate logs on a monthly basis, open your `app/Console/Kernel.php` file and add the following to the `schedule()` method:\n\n```php\nprotected function schedule(Schedule $schedule)\n{\n    $schedule-\u003ecall(function () {\n        app('logrotator')-\u003erotate();\n    })-\u003emonthly();\n}\n```\nFor **Laravel 11.x**, You can create a scheduled command on `routes/console.php` file:\n```php\nArtisan::command('logrotation:rotate', function () {\n    app('logrotator')-\u003erotate();\n})-\u003emonthly();\n```\n\nThis will ensure that logs are rotated and that older logs are automatically deleted at the beginning of every month.\n\n\n## Advanced Customization\n\nIf you want to change the default log location or customize the log retention behavior, you can extend the `LogRotator` class and override its methods. By default, the package manages the `storage/logs/laravel.log` file, but you can pass a custom log file path when initializing the class:\n\n```php\nuse AlkhatibDev\\LogRotation\\LogRotator;\n\n$logRotator = new LogRotator();\n$logRotator\n    -\u003esetLogFile(storage_path('logs/custom.log')) // Set the log file path to rotate\n    -\u003erotate();\n```\n\n## Support\n\nIf you encounter any issues or have feature requests, feel free to [open an issue](https://github.com/alkhatibdev/logrotation/issues) on GitHub.\n\n## License\n\nThis package is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkhatibdev%2Flogrotation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkhatibdev%2Flogrotation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkhatibdev%2Flogrotation/lists"}