{"id":20051930,"url":"https://github.com/dekobon/log4j2-bunyan-layout","last_synced_at":"2026-05-07T23:46:22.837Z","repository":{"id":45155964,"uuid":"431541882","full_name":"dekobon/log4j2-bunyan-layout","owner":"dekobon","description":"Bunyan Layout for Log4j2","archived":false,"fork":false,"pushed_at":"2023-04-03T15:45:29.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-13T17:22:07.322Z","etag":null,"topics":["bunyan","layout","log4j2","log4j2-layout","logging"],"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/dekobon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-11-24T15:46:23.000Z","updated_at":"2022-01-05T19:52:00.000Z","dependencies_parsed_at":"2025-03-02T08:43:07.146Z","dependency_job_id":"0c5cf837-59f1-4b2a-a72a-8cd3b185c3c9","html_url":"https://github.com/dekobon/log4j2-bunyan-layout","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/dekobon/log4j2-bunyan-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekobon%2Flog4j2-bunyan-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekobon%2Flog4j2-bunyan-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekobon%2Flog4j2-bunyan-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekobon%2Flog4j2-bunyan-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dekobon","download_url":"https://codeload.github.com/dekobon/log4j2-bunyan-layout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dekobon%2Flog4j2-bunyan-layout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32760958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bunyan","layout","log4j2","log4j2-layout","logging"],"created_at":"2024-11-13T12:08:32.682Z","updated_at":"2026-05-07T23:46:22.813Z","avatar_url":"https://github.com/dekobon.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Log4j2 Bunyan Layout\n[![Continuous Integration](https://github.com/dekobon/log4j2-bunyan-layout/actions/workflows/ci.yaml/badge.svg)](https://github.com/dekobon/log4j2-bunyan-layout/actions/workflows/ci.yaml)\n\n![Screenshot](docs/screenshot.png)\n\n## Overview\n\nThis project provides a custom [Log4j Layout](https://logging.apache.org/log4j/2.x/manual/layouts.html)\nthat outputs structured logs in the [Bunyan JSON](https://github.com/trentm/node-bunyan)\nformat. Similar to Log4j `log4j2-bunyan-layout` aims to \n[minimize object creation and thereby garbage collection](https://logging.apache.org/log4j/2.x/manual/garbagefree.html). Additionally, `log4j2-bunyan-layout` uses the\n[DSL-JSON library](https://github.com/ngs-doo/dsl-json) for fast JSON\nserialization.\n\n## Configuration\n\nAdd a dependency definition to your Maven pom.xml:\n```xml\n\u003cproject\u003e\n    ...\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eorg.apache.logging.log4j\u003c/groupId\u003e\n            \u003cartifactId\u003elog4j-core\u003c/artifactId\u003e\n            \u003cversion\u003e2.16.0\u003c/version\u003e\n        \u003c/dependency\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.dekobon\u003c/groupId\u003e\n            \u003cartifactId\u003elog4j2-bunyan-layout\u003c/artifactId\u003e\n            \u003cversion\u003e1.0.3\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/project\u003e\n```\n\nEdit your log4j2 configuration such that you have added it as a layout to your\nappender. For example, a minimal configuration would look like:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cConfiguration\u003e\n    \u003cAppenders\u003e\n        \u003cFile name=\"MyFile\" fileName=\"output.json\"\u003e\n            \u003cBunyanJsonLayout appName=\"space-explorer\"/\u003e\n        \u003c/File\u003e\n    \u003c/Appenders\u003e\n    \u003cLoggers\u003e\n        \u003cRoot level=\"debug\"\u003e\n            \u003cAppenderRef ref=\"MyFile\"/\u003e\n        \u003c/Root\u003e\n    \u003c/Loggers\u003e\n\u003c/Configuration\u003e\n```\n\nA more robust configuration may look like:\n\n```xml\n...\n        \u003cFile name=\"MyFile\" fileName=\"output.json\"\u003e\n            \u003cBunyanJsonLayout appName=\"road-hopper\" endOfLine=\"\\n\" maxMessageLength=\"1000\" properties=\"false\"\u003e\n                \u003cThrowableFormat format=\"extended\" ignorePackages=\"org.junit\"/\u003e\n                \u003cKeyValuePair key=\"additionalField\" value=\"constant value\"/\u003e\n                \u003cKeyValuePair key=\"traceId\" value=\"$${ctx:trace_id:-}\"/\u003e\n            \u003c/BunyanJsonLayout\u003e\n        \u003c/File\u003e\n...\n```\n\nThe layout has the following properties.\n\n### `BunyanJsonLayout`\n * `appName` (required) - string to use as application name in bunyan log messages.\n * `endOfLine` - string to append to the end of each JSON object (default: (Unix new line) `\\n`).\n   This property accepts Java style escaped values such as: `\\n`, `\\r`, `\\t`, `\\0`. \n   If there are octals, unicode, or any sort of non-trivial escapes in\n   this value, Java 15+ must be used or the Apache Commons Text library must be\n   loaded.\n * `maxMessageLength` - size in characters to truncate log messages to (default: `32768`).\n * `properties` - flag when set to true enables the output of *all* [context properties](https://logging.apache.org/log4j/2.x/manual/thread-context.html) (default: `false`).\n\n### `ThrowableFormat` (Optional element - only a single element is valid)\n * `format` - pattern in which to format exception (throwable) stack traces that \n   are associated  with a log event. If `format` is specified `depth` may not be \n   specified. Format can be set to any of the following values:\n   * `none` - no stacktrace is output.\n   * `full` - the full stacktrace is output (default).\n   * `extended` - outputs the full stacktrace including the location of where \n      the class was loaded from and the version of the jar if available.\n   * `short` - outputs the first line of the Throwable.\n   * `short.className` - outputs the name of the class where the exception occurred.\n   * `short.methodName` - outputs the method name where the exception occurred.\n   * `short.lineNumber` - outputs the line number where the exception occurred.\n   * `short.fileName` - outputs the name of the file where the exception occurred.\n   * `short.message` - outputs only the message.\n   * `short.localizedMessage` - outputs the localized message.\n * `depth` - number of lines of the stack trace to output. If `depth` is \n   specified `format` may not be specified.\n * `ignorePackages` - a comma delimited list of Java packages to suppress \n   matching stack frames from stack traces. \n\n### `KeyValuePair` (Optional element - many elements may be defined) \n * `key` - String indicating the name of the value to be output as an additional\n   log attribute.\n * `value` - A string constant to output as an additional log attribute, or\n   alternatively a dynamic value defined using \n   [Log4j2's lookup syntax](https://logging.apache.org/log4j/2.x/manual/lookups.html).\n\n## License\n\nThis project is licensed under the [Apache License v2 license](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekobon%2Flog4j2-bunyan-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdekobon%2Flog4j2-bunyan-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdekobon%2Flog4j2-bunyan-layout/lists"}