{"id":13617397,"url":"https://github.com/EasyCorp/easy-log-handler","last_synced_at":"2025-04-14T06:33:38.073Z","repository":{"id":56974406,"uuid":"65798229","full_name":"EasyCorp/easy-log-handler","owner":"EasyCorp","description":"Human-friendly log files that make you more productive","archived":true,"fork":false,"pushed_at":"2020-04-07T10:11:29.000Z","size":36,"stargazers_count":2024,"open_issues_count":0,"forks_count":29,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-04T16:43:18.615Z","etag":null,"topics":["dx","log","logger","monolog","monolog-handler","php","symfony"],"latest_commit_sha":null,"homepage":"https://easycorp.io/EasyLog","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/EasyCorp.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}},"created_at":"2016-08-16T07:36:07.000Z","updated_at":"2025-04-01T06:33:31.000Z","dependencies_parsed_at":"2022-08-21T07:40:31.388Z","dependency_job_id":null,"html_url":"https://github.com/EasyCorp/easy-log-handler","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyCorp%2Feasy-log-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyCorp%2Feasy-log-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyCorp%2Feasy-log-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EasyCorp%2Feasy-log-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EasyCorp","download_url":"https://codeload.github.com/EasyCorp/easy-log-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436252,"owners_count":20938533,"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":["dx","log","logger","monolog","monolog-handler","php","symfony"],"created_at":"2024-08-01T20:01:41.101Z","updated_at":"2025-04-14T06:33:37.797Z","avatar_url":"https://github.com/EasyCorp.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"EasyLogHandler (human-friendly log files)\n=========================================\n\nSymfony log files are formatted in the same way for all environments. This means that `dev.log` is optimized for machines instead of humans. The result is a log file bloated with useless information that makes you less productive.\n\n**EasyLogHandler** is a new Monolog handler that creates human-friendly log files. It's optimized to display the log information in a clear and concise way. Use it in the development environment to become a much more productive developer.\n\n1. [Features](#features)\n2. [Installation](#installation)\n3. [Configuration and Usage](#configuration-and-usage)\n\n----\n\nFeatures\n--------\n\nThese are some of the best features of **EasyLogHandler** and how it compares itself with the default Symfony logs.\n\n### Better Log Structure\n\nSymfony log files are a huge stream of text. When you open them, you can't easily tell when a request started or finished and which log messages belong together:\n\n| Symfony | EasyLogHandler\n| ------- | --------------\n| ![structure-overview-symfony-mini](https://cloud.githubusercontent.com/assets/73419/17691467/e838b0b2-6394-11e6-9028-bfa04adc36c1.png) | ![structure-overview-easylog-mini](https://cloud.githubusercontent.com/assets/73419/17691466/e8336c88-6394-11e6-9a13-32146e2bdb6f.png)\n\nEasyLogHandler structures the log files in a different way:\n\n![structure-easylog](https://cloud.githubusercontent.com/assets/73419/17691552/788c4138-6395-11e6-8436-36051a4eb0da.png)\n\n* It adds a large header and some new lines to separate each request logs;\n* If the request is less significant (e.g. Assetic requests) the header is more compact and displays less information;\n* Log messages are divided internally so you can better understand their different parts (request, doctrine, security, etc.)\n\n### Less Verbose Logs\n\nFirst of all, EasyLogHandler doesn't display the timestamp in every log message. In the `dev` environment you shouldn't care about that, so the timestamp is only displayed once for each group of log messages.\n\n| Symfony | EasyLogHandler\n| ------- | --------------\n| ![timestamps-symfony](https://cloud.githubusercontent.com/assets/73419/17691577/9f0bce78-6395-11e6-8e6b-f2ae3354342b.png) | ![timestamps-easylog](https://cloud.githubusercontent.com/assets/73419/17691578/9f4ceed0-6395-11e6-96ea-aada7577e1b2.png)\n\nThe `extra` information, which some log messages include to add more details about the log, is displayed only when it's different from the previous log. In contrast, Symfony always displays the `extra` for all logs, generating a lot of duplicated information:\n\n| Symfony\n| -------\n| ![extra-symfony](https://cloud.githubusercontent.com/assets/73419/17691601/c17f2996-6395-11e6-876b-fbd87422c04d.png)\n\n| EasyLogHandler\n| -------\n| ![extra-easylog](https://cloud.githubusercontent.com/assets/73419/17691600/c13fe75e-6395-11e6-92db-bb8457967642.png)\n\nIt's becoming increasingly popular to use placeholders in log messages instead of the actual values (e.g. `Matched route \"{route}\".` instead of `Matched route \"home\".`) This is great for machines, because they can group similar messages that only vary in the placeholder values.\n\nHowever, for humans this \"feature\" is disturbing. That's why EasyLogHandler automatically replaces any placeholder included in the log message:\n\n| Symfony\n| -------\n| ![placeholders-symfony](https://cloud.githubusercontent.com/assets/73419/17691694/541e4a20-6396-11e6-8400-546383a69755.png)\n\n| EasyLogHandler\n| --------------\n| ![placeholder-easylog](https://cloud.githubusercontent.com/assets/73419/17691695/545b2f9e-6396-11e6-9b46-814c6dcde9e0.png)\n\n### Better Visual Hierarchy\n\nImportant elements, such as deprecations and security-related messages, must stand out in log files to help you spot them instantly. However, in Symfony all logs look exactly the same. How can you know which are the important ones?\n\n| Symfony\n| -------\n| ![visual-hierarchy-symfony](https://cloud.githubusercontent.com/assets/73419/17691756/a0164edc-6396-11e6-949a-73e973219d13.png) \u003cbr\u003e (all messages look exactly the same)\n\n| EasyLogHandler\n| --------------\n| ![visual-hierarchy-easylog](https://cloud.githubusercontent.com/assets/73419/17691755/9fe3b86e-6396-11e6-9308-abaeb8c5b823.png) \u003cbr\u003e (deprecations, warnings, errors and security messages stand out)\n\n### Dynamic Variable Inlining\n\nLog messages usually contain related variables in their `context` and `extra` properties. Displaying the content of these variables in the log files is always a tough balance between readability and conciseness.\n\nEasyLogHandler decides how to inline these variables dynamically depending on each log message. For example, Doctrine query parameters are always inlined but request parameters are inlined for unimportant requests and nested for important requests:\n\n![dynamic-inline-easylog](https://cloud.githubusercontent.com/assets/73419/17691843/2fde6324-6397-11e6-8627-e7c04528c6b3.png)\n\n### Stack Traces\n\nWhen log messages include error stack traces, you definitely want to take a look at them. However, Symfony displays stack traces inlined, making them impossible to inspect. EasyLogHandler displays them as proper stack traces:\n\n| Symfony\n| -------\n| ![stack-trace-symfony](https://cloud.githubusercontent.com/assets/73419/17691905/716839d2-6397-11e6-8d45-b8be84ad9596.png)\n\n| EasyLogHandler\n| --------------\n| ![stack-trace-easylog](https://cloud.githubusercontent.com/assets/73419/17691908/72190302-6397-11e6-95c0-8c9c0b570d97.png)\n\n### Log Message Grouping\n\nOne of the most frustrating experiences when inspecting log files is having lots of repeated or similar consecutive messages. They provide little information and they just distract you. EasyLogHandler process all log messages at once instead of one by one, so it's aware when there are similar consecutive logs.\n\nFor example, this is a Symfony log file displaying three consecutive missing translation messages:\n\n![translation-group-symfony](https://cloud.githubusercontent.com/assets/73419/17691954/b76ef04c-6397-11e6-9127-675ae831fd31.png)\n\nAnd this is how the same messages are displayed by EasyLogHandler:\n\n![translation-group-easylog](https://cloud.githubusercontent.com/assets/73419/17691955/b895ca86-6397-11e6-83c8-e5d6da4dbdf3.png)\n\nThe difference is even more evident for \"event notified\" messages, which usually generate tens of consecutive messages:\n\n| Symfony\n| -------\n| ![event-group-symfony](https://cloud.githubusercontent.com/assets/73419/17691951/b447634a-6397-11e6-8482-265d7b02ead6.png)\n\n| EasyLogHandler\n| --------------\n| ![event-group-easylog](https://cloud.githubusercontent.com/assets/73419/17691952/b5f5fd96-6397-11e6-8fc6-8835e6be7824.png)\n\nInstallation\n------------\n\nThis project is distributed as a PHP package instead of a Symfony bundle, so you just need to require the project with [Composer](https://getcomposer.org):\n\n```bash\n$ composer require --dev easycorp/easy-log-handler\n```\n\nConfiguration and Usage\n-----------------------\n\n### Step 1\n\nDefine a new service in your application for this log handler:\n\nNewer Symfony version:\n\n```yaml\n# config/packages/dev/easy_log_handler.yaml\nservices:\n    EasyCorp\\EasyLog\\EasyLogHandler:\n        public: false\n        arguments: ['%kernel.logs_dir%/%kernel.environment%.log']\n\n```\n\nOlder Symfony version:\n\n```yaml\n# app/config/services.yml\nservices:\n    # ...\n    easycorp.easylog.handler:\n        class: EasyCorp\\EasyLog\\EasyLogHandler\n        public: false\n        arguments:\n            - '%kernel.logs_dir%/%kernel.environment%.log'\n```\n\n### Step 2\n\nUpdate your Monolog configuration in the `dev` environment to define a buffered handler\nthat wraps this new handler service (keep reading to understand why).\nYou can safely copy+paste this configuration:\n\nNewer Symfony version:\n\n```yaml\n# config/packages/dev/monolog.yaml\nmonolog:\n    handlers:\n        buffered:\n            type:     buffer\n            handler:  easylog\n            channels: ['!event']\n            level:    debug\n        easylog:\n            type: service\n            id:   EasyCorp\\EasyLog\\EasyLogHandler\n```\n\nOlder Symfony version:\n\n```yaml\n# app/config/config_dev.yml\nmonolog:\n    handlers:\n        buffered:\n            type:     buffer\n            handler:  easylog\n            channels: [\"!event\"]\n            level:    debug\n        easylog:\n            type: service\n            id:   easycorp.easylog.handler\n```\n\nMost log handlers treat each log message separately. In contrast, EasyLogHandler advanced log processing requires each log message to be aware of the other logs (for example to merge similar consecutive messages). This means that all the logs associated with the request must be captured and processed in batch.\n\nIn the above configuration, the `buffered` handler saves all log messages and then passes them to the EasyLog handler, which processes all messages at once and writes the result in the log file.\n\nUse the `buffered` handler to configure the channels logged/excluded and the level of the messages being logged.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEasyCorp%2Feasy-log-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEasyCorp%2Feasy-log-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEasyCorp%2Feasy-log-handler/lists"}