{"id":18736518,"url":"https://github.com/hapag-lloyd/log4j2-filtered-stacktrace-plugin","last_synced_at":"2025-08-12T00:38:16.226Z","repository":{"id":227923675,"uuid":"772601256","full_name":"Hapag-Lloyd/log4j2-filtered-stacktrace-plugin","owner":"Hapag-Lloyd","description":"Plugin for Log4j2 to reduce noise in stacktraces.","archived":false,"fork":false,"pushed_at":"2025-08-01T00:05:22.000Z","size":335,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-08-03T01:19:54.248Z","etag":null,"topics":["filter","java","log4j2","logger","logging","plugin","stacktrace"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hapag-Lloyd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-15T14:14:16.000Z","updated_at":"2025-08-01T00:05:26.000Z","dependencies_parsed_at":"2025-05-30T12:27:20.218Z","dependency_job_id":"35bc62d9-9f97-4033-8cb5-2620ced06308","html_url":"https://github.com/Hapag-Lloyd/log4j2-filtered-stacktrace-plugin","commit_stats":null,"previous_names":["hapag-lloyd/log4j2-filtered-stacktrace-plugin"],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/Hapag-Lloyd/log4j2-filtered-stacktrace-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hapag-Lloyd%2Flog4j2-filtered-stacktrace-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hapag-Lloyd%2Flog4j2-filtered-stacktrace-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hapag-Lloyd%2Flog4j2-filtered-stacktrace-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hapag-Lloyd%2Flog4j2-filtered-stacktrace-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hapag-Lloyd","download_url":"https://codeload.github.com/Hapag-Lloyd/log4j2-filtered-stacktrace-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hapag-Lloyd%2Flog4j2-filtered-stacktrace-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269981428,"owners_count":24507276,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["filter","java","log4j2","logger","logging","plugin","stacktrace"],"created_at":"2024-11-07T15:21:13.776Z","updated_at":"2025-08-12T00:38:16.202Z","avatar_url":"https://github.com/Hapag-Lloyd.png","language":"Java","readme":"\u003c!-- First line should be an H1: Badges on top please! --\u003e\n\u003c!-- markdownlint-disable first-line-h1 --\u003e\n[![Actions](https://github.com/Hapag-Lloyd/log4j2-filtered-stacktrace-plugin/workflows/Release/badge.svg)](https://github.com/Hapag-Lloyd/log4j2-filtered-stacktrace-plugin/actions)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.hlag.logging/log4j2-stacktrace-filter/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.hlag.logging/log4j2-stacktrace-filter-plugin)\n\u003c!-- markdownlint-enable first-line-h1 --\u003e\n\n# Filter Stacktrace Plugin for Log4j2\n\nThis project contains a stacktrace filter for the Log4j2 logging system. It can be included in a [`JsonTemplateLayout`](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html).\n\nThe plugin reduces the stacktrace by filtering classes which are not of any interest. It has a built-in list of packages to exclude\nfrom the stacktrace. Additional packages can be configured in the `log4j2.xml` file. Find the full blown example below.\n\nThis plugin was built on top of the work of the Apache Log4j team and takanuva15, who described the plugin in a\n[Stackoverflow article](https://stackoverflow.com/questions/70614495/is-there-a-way-to-override-the-exceptionresolver-of-jsontemplatelayout-of-log4j2/77143208#77143208).\nWe replaced the main logic completely.\n\n# Output\n\nAdding the filter to the logging configuration with `\u003cEventTemplateAdditionalField key=\"error\" format=\"JSON\" value='{\"$resolver\": \"filteredStacktraceException\"}'/\u003e`\nproduces the following Json object in the log stream:\n\n\u003c!-- no line breaks in Json please, we are fine with long lines here --\u003e\n\u003c!-- markdownlint-disable line-length --\u003e\n```json\n\"error\": {\n  \"stack\": \"java.lang.RuntimeException: java.lang.ArithmeticException: / by zero\\r\\n\\tat com.hlag.logging.log4j2.LoggerIntegrationTest.wrapException(LoggerIntegrationTest.java:21)\\r\\n\\tat com.hlag.logging.log4j2.LoggerIntegrationTest.logException(LoggerIntegrationTest.java:11)\\r\\n\\t[suppressed 70 lines]\\r\\nCaused by java.lang.ArithmeticException: / by zero\\r\\n\\tat com.hlag.logging.log4j2.LoggerIntegrationTest.throwArithmeticException(LoggerIntegrationTest.java:25)\\r\\n\\tat com.hlag.logging.log4j2.LoggerIntegrationTest.wrapException(LoggerIntegrationTest.java:19)\\r\\n\\tat com.hlag.logging.log4j2.LoggerIntegrationTest.logException(LoggerIntegrationTest.java:11)\\r\\n\\t[suppressed 70 lines]\",\n  \"name\": \"java.lang.RuntimeException\",\n  \"message\": \"java.lang.ArithmeticException: / by zero\",\n  \"totalFilteredElements\": 140\n}\n```\n\u003c!-- markdownlint-enable line-length --\u003e\n\n140 elements have been removed from the stacktrace. Only those remain which are relevant for your application.\n\n# Usage\n\n## Maven Dependency\n\nInclude the following artifact to your project which contains the `log4j2.xml` configuration file. Make sure to use the newest version.\n\n```xml\n\u003c!-- pom.xml --\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.hlag.logging\u003c/groupId\u003e\n    \u003cartifactId\u003elog4j2-stacktrace-filter\u003c/artifactId\u003e\n    \u003c!-- make sure to use the newest version --\u003e\n    \u003cversion\u003e1.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Log4j2 Configuration\n\n\u003c!-- no line breaks in Json please, we are fine with long lines here --\u003e\n\u003c!-- markdownlint-disable line-length --\u003e\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!-- log4j2.xml --\u003e\n\u003cConfiguration status=\"INFO\"\u003e\n\n    \u003cAppenders\u003e\n        \u003cConsole name=\"console\" target=\"SYSTEM_OUT\"\u003e\n            \u003cJsonTemplateLayout eventTemplateUri=\"classpath:JsonLayout.json\" maxStringLength=\"32768\"  stackTraceEnabled=\"false\"\u003e\n                \u003cEventTemplateAdditionalField key=\"error\" format=\"JSON\"\n                                              value='{\"$resolver\": \"filteredStacktraceException\"}, \"additionalPackagesToIgnore\": [\"com.hlag.logging.log4j2.\"]}' /\u003e\n            \u003c/JsonTemplateLayout\u003e\n        \u003c/Console\u003e\n    \u003c/Appenders\u003e\n\n    \u003cLoggers\u003e\n      \u003cRoot level=\"info\"\u003e\n          \u003cappender-ref ref=\"console\" /\u003e\n      \u003c/Root\u003e\n    \u003c/Loggers\u003e\n\u003c/Configuration\u003e\n```\n\u003c!-- markdownlint-enable line-length --\u003e\n\n### additionalPackagesToIgnore\n\nUse this parameter to add other packages to the built-in list. These packages are ignored too. Especially useful if you have to\ninclude company internal frameworks, but you don't want to see them in the stacktrace.\n\nMakes no sense to specify `whitelistedPackages` in addition to this parameter.\n\n### whitelistPackages\n\nUse this parameter to define packages which should remain when filtering a stack trace. Every other package is removed from the\nstacktrace. The built-in list of packages to filter as well as the `additionalPackagesToIgnore` parameter have no effect when\n`whitelistPackages` exists.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapag-lloyd%2Flog4j2-filtered-stacktrace-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapag-lloyd%2Flog4j2-filtered-stacktrace-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapag-lloyd%2Flog4j2-filtered-stacktrace-plugin/lists"}