{"id":25750703,"url":"https://github.com/chelout/laravel-http-logger","last_synced_at":"2025-05-12T16:29:54.306Z","repository":{"id":62501312,"uuid":"127915216","full_name":"chelout/laravel-http-logger","owner":"chelout","description":"Log HTTP requests, headers and session data in Laravel","archived":false,"fork":false,"pushed_at":"2019-07-05T12:18:27.000Z","size":26,"stargazers_count":26,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T00:34:24.334Z","etag":null,"topics":["headers","laravel","log","logger","logging","request","session"],"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/chelout.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-03T13:47:54.000Z","updated_at":"2024-11-20T12:42:48.000Z","dependencies_parsed_at":"2022-11-02T11:48:03.142Z","dependency_job_id":null,"html_url":"https://github.com/chelout/laravel-http-logger","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chelout%2Flaravel-http-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chelout%2Flaravel-http-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chelout%2Flaravel-http-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chelout%2Flaravel-http-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chelout","download_url":"https://codeload.github.com/chelout/laravel-http-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253776501,"owners_count":21962499,"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":["headers","laravel","log","logger","logging","request","session"],"created_at":"2025-02-26T13:19:26.851Z","updated_at":"2025-05-12T16:29:54.283Z","avatar_url":"https://github.com/chelout.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Log HTTP requests, headers and session data\n[![Latest Stable Version](https://poser.pugx.org/chelout/laravel-http-logger/v/stable)](https://packagist.org/packages/chelout/laravel-http-logger)\n[![Total Downloads](https://poser.pugx.org/chelout/laravel-http-logger/downloads)](https://packagist.org/packages/chelout/laravel-http-logger)\n[![License](https://poser.pugx.org/chelout/laravel-http-logger/license)](https://packagist.org/packages/chelout/laravel-http-logger)\n\nThis package provides a middleware to log incoming http requests data (body data, files, headers and session data). It utilizes [Laravel 5.6 logging servises](https://laravel.com/docs/5.6/logging) functionality.\nThis package might be useful to log user requests to public apis.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require chelout/laravel-http-logger\n```\n\nOptionally you can publish the configfile with:\n\n```bash\nphp artisan vendor:publish --provider=\"Chelout\\HttpLogger\\HttpLoggerServiceProvider\" --tag=\"config\" \n```\n\nThis is the contents of the published config file:\n\n```php\n\nreturn [\n    /*\n     * Log file path\n     */\n    'path' =\u003e storage_path('logs/http.log'),\n    /*\n     * The maximal amount of files to keep (0 means unlimited)\n     */\n    'max_files' =\u003e 5,\n\n    /*\n     * Log methods\n     * [] - log all methods\n     * ['get','post'] - log only 'get' and 'post' methods\n     */\n    'methods' =\u003e [],\n\n    /*\n     * Log message format.\n     * For for details see https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#customizing-the-log-format\n     * and https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php\n     */\n    'format' =\u003e \"[%datetime%] %extra.method% %extra.url% from %extra.ips% %context%\\n\",\n\n    /*\n     * Log message datetime format.\n     * For for details see https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#customizing-the-log-format\n     * and https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php\n     */\n    'date_format' =\u003e null, // \"Y-m-d\\TH:i:sP\"\n\n    /*\n     * Log current memory usage\n     * @see https://github.com/Seldaek/monolog/blob/master/src/Monolog/Processor/MemoryUsageProcessor.php\n     */\n    'memory_usage' =\u003e true,\n\n    /*\n     * Log peak memory usage\n     * @see https://github.com/Seldaek/monolog/blob/master/src/Monolog/Processor/MemoryPeakUsageProcessor.php\n     */\n    'memory_peak_usage' =\u003e true,\n\n    /*\n     * Log current git branch and commit\n     * @see https://github.com/Seldaek/monolog/blob/master/src/Monolog/Processor/GitProcessor.php\n     */\n    'git' =\u003e true,\n\n    /*\n     * false - don't log body fields\n     * ['only'] - log fields only\n     * ['except'] - don't log fields\n     *\n     * If ['only'] is set, ['except'] parametr will be omitted\n     */\n    // 'data' =\u003e false,\n    'data' =\u003e [\n        'only' =\u003e [],\n        'except' =\u003e [],\n    ],\n\n    /*\n     * false - don't log uploaded files\n     * ['only'] - log files only\n     * ['except'] - don't log files\n     *\n     * If ['only'] is set, ['except'] parametr will be omitted\n     */\n    // 'files' =\u003e false,\n    'files' =\u003e [\n        'only' =\u003e [],\n        'except' =\u003e [],\n    ],\n\n    /*\n     * false - don't log headers\n     * ['only'] - log headers only\n     * ['except'] - don't log headers\n     *\n     * If ['only'] is set, ['except'] parametr will be omitted\n     */\n    // 'headers' =\u003e false,\n    'headers' =\u003e [\n        'only' =\u003e ['user-agent'],\n        'except' =\u003e [],\n    ],\n\n    /*\n     * false - don't log session\n     * ['only'] - log session only\n     * ['except'] - don't log session\n     *\n     * If ['only'] is set, ['except'] parametr will be omitted\n     */\n    'session' =\u003e false,\n    // 'session' =\u003e [\n    //     'only' =\u003e [],\n    //     'except' =\u003e [],\n    // ],\n];\n\n```\n\n## Usage\n\nThis packages provides a middleware which can be added as a global middleware or as a single route.\n\n```php\n// in `app/Http/Kernel.php`\n\nprotected $middleware = [\n    // ...\n    \n    \\Chelout\\HttpLogger\\Middlewares\\HttpLogger::class\n];\n```\n\n```php\n// in a routes file\n\nRoute::post('/submit-form', function () {\n    //\n})-\u003emiddleware(\\Chelout\\HttpLogger\\Middlewares\\HttpLogger::class);\n```\n\nIn order to log http requests you should add log custom log channel:\n```php\n// in config/logging.php\n\nreturn [\n    // ...\n\n    'channels' =\u003e [\n        // ...\n\n        'http-logger' =\u003e [\n            'driver' =\u003e 'custom',\n            'via' =\u003e \\Chelout\\HttpLogger\\Loggers\\HttpLogger::class,\n        ],\n    ],\n];\n```\n\nYou can also enhance existing log channel by customizing Monolog configuration:\n```php\n// in config/logging.php\n\nreturn [\n    // ...\n\n    'channels' =\u003e [\n        // ...\n\n        'single' =\u003e [\n            'driver' =\u003e 'single',\n            'tap' =\u003e [Chelout\\HttpLogger\\Loggers\\MonologCustomizer::class],\n            'path' =\u003e storage_path('logs/laravel.log'),\n            'level' =\u003e 'debug',\n        ],\n    ],\n];\n```\n\n### Todo\n- tests\n- log git data?\n- log memory usage?\n\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Inspiration\nThis package was inspired by [Log HTTP requests](https://github.com/spatie/laravel-http-logger) and [Laravel Log Enhancer](https://github.com/freshbitsweb/laravel-log-enhancer) and [Laravel 5.6 logging servises](https://laravel.com/docs/5.6/logging).\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Viacheslav Ostrovskiy](https://github.com/cheelout)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchelout%2Flaravel-http-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchelout%2Flaravel-http-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchelout%2Flaravel-http-logger/lists"}