{"id":23501208,"url":"https://github.com/aviationcode/laravel-ecs-logging","last_synced_at":"2025-04-15T19:42:11.865Z","repository":{"id":46661505,"uuid":"244239981","full_name":"AviationCode/laravel-ecs-logging","owner":"AviationCode","description":"Adding ECS (Elastic Common Schema) Logging to laravel","archived":false,"fork":false,"pushed_at":"2021-10-01T10:18:42.000Z","size":32,"stargazers_count":2,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T00:23:30.082Z","etag":null,"topics":["elasticsearch","error-monitoring","hacktoberfest","kibana","laravel","logging"],"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/AviationCode.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":"2020-03-01T23:25:31.000Z","updated_at":"2021-10-01T10:17:16.000Z","dependencies_parsed_at":"2022-08-28T16:10:54.805Z","dependency_job_id":null,"html_url":"https://github.com/AviationCode/laravel-ecs-logging","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviationCode%2Flaravel-ecs-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviationCode%2Flaravel-ecs-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviationCode%2Flaravel-ecs-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AviationCode%2Flaravel-ecs-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AviationCode","download_url":"https://codeload.github.com/AviationCode/laravel-ecs-logging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249140593,"owners_count":21219323,"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":["elasticsearch","error-monitoring","hacktoberfest","kibana","laravel","logging"],"created_at":"2024-12-25T07:13:37.466Z","updated_at":"2025-04-15T19:42:11.847Z","avatar_url":"https://github.com/AviationCode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Elastic Common Scheme (ECS) Logging \n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/aviationcode/laravel-ecs-logging.svg?style=flat-square)](https://packagist.org/packages/aviationcode/laravel-ecs-logging)\n[![Build Status](https://img.shields.io/travis/aviationcode/laravel-ecs-logging/master.svg?style=flat-square)](https://travis-ci.org/aviationcode/laravel-ecs-logging)\n[![Total Downloads](https://img.shields.io/packagist/dt/aviationcode/laravel-ecs-logging.svg?style=flat-square)](https://packagist.org/packages/aviationcode/laravel-ecs-logging)\n\nThis package adds ECS (Elastic Common Scheme) format to your laravel application allowing to log your standard logs to elastic.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require aviationcode/laravel-ecs-logging\n```\n\nIt's recommended to require `jenssegers/agent` which will add user agent logging support.\n\n```bash\ncomposer require jenssegers/agent\n```\n\nOptionally, you can publish the config file with:\n\n```bash\nphp artisan vendor:publish --provider=\"AviationCode\\EcsLogging\\EcsLoggingServiceProvider\" --tag=\"config\"\n```\n\nRegister log driver in `config/logging.php`\n\n```php\nreturn [\n    'channels' =\u003e [\n        // ... Other channels\n\n        'ecs' =\u003e [\n            'driver' =\u003e 'ecs',\n            'path' =\u003e storage_path('logs/ecs/laravel.json'),\n            'level' =\u003e 'debug',\n            'days' =\u003e 14,\n        ],\n    ]\n];\n```\n\nIf you want to use this driver as the only logging method define `LOG_CHANNEL=ecs` in your `.env` or add the `ecs` channel into your stack driver.\n\nAll `Log::xxx()` calls get logged into json file. This file can be picked up by filebeat which sends it to your logstash or elasticsearch instance.\n\n### Configure filebeat\n\nAdd the following to your `/etc/filebeat/filebeat.yml` file\n\n```yaml\nfilebeat.inputs:\n  - type: log\n    enabled: true\n    paths:\n      - /path-to-your-laravel-app/storage/logs/ecs/*.json\n    json:\n      message_key: message\n      keys_under_root: true\n      overwrite_keys: true\n```\n\n## Usage\n\n\n### Event\n\n[Event](https://www.elastic.co/guide/en/ecs/current/ecs-event.html) defines something that happened, this could be a single point in time or lasting a certain period.\nIn order to log an event you can add this log context.\n\n```php\nLog::info('Password changed for John Doe\u003cjohn.doe@example.com\u003e', [\n    'event' =\u003e [\n        'action' =\u003e 'user-password-change',\n        'code' =\u003e 4648,\n        'outcome' =\u003e \\AviationCode\\EcsLogging\\Types\\Event::OUTCOME_SUCCESS,\n        'type' =\u003e 'user',\n    ],\n]);\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## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email ken.andries.1992@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Ken Andries](https://github.com/DouglasDC3)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faviationcode%2Flaravel-ecs-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faviationcode%2Flaravel-ecs-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faviationcode%2Flaravel-ecs-logging/lists"}