{"id":27957447,"url":"https://github.com/dubasdey/log4j2-jsonevent-layout","last_synced_at":"2025-10-20T05:22:17.200Z","repository":{"id":20516944,"uuid":"90132958","full_name":"dubasdey/log4j2-jsonevent-layout","owner":"dubasdey","description":"Log4j2 JSON Event Layout without requirement of thirdparty libraries","archived":false,"fork":false,"pushed_at":"2024-09-25T17:20:26.000Z","size":122,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T18:12:56.573Z","etag":null,"topics":["json","log","log4j","log4j2","log4j2-layout","logging-library","logstash"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dubasdey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.paypal.com/donate/?hosted_button_id=K6DQ5GLE8KHGY"]}},"created_at":"2017-05-03T09:40:51.000Z","updated_at":"2024-10-15T12:10:13.000Z","dependencies_parsed_at":"2023-02-12T17:31:04.886Z","dependency_job_id":null,"html_url":"https://github.com/dubasdey/log4j2-jsonevent-layout","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubasdey%2Flog4j2-jsonevent-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubasdey%2Flog4j2-jsonevent-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubasdey%2Flog4j2-jsonevent-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dubasdey%2Flog4j2-jsonevent-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dubasdey","download_url":"https://codeload.github.com/dubasdey/log4j2-jsonevent-layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931554,"owners_count":21827112,"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":["json","log","log4j","log4j2","log4j2-layout","logging-library","logstash"],"created_at":"2025-05-07T18:13:02.037Z","updated_at":"2025-10-20T05:22:17.182Z","avatar_url":"https://github.com/dubasdey.png","language":"Java","funding_links":["https://www.paypal.com/donate/?hosted_button_id=K6DQ5GLE8KHGY"],"categories":[],"sub_categories":[],"readme":"# log4j2-jsonevent-layout\n\n[![GitHub license](https://img.shields.io/badge/license-LGPL-blue.svg)](https://raw.githubusercontent.com/dubasdey/log4j2-jsonevent-layout/master/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/dubasdey/log4j2-jsonevent-layout.svg)](https://github.com/dubasdey/log4j2-jsonevent-layout/issues)\n[![CI Build Status](https://github.com/dubasdey/log4j2-jsonevent-layout/actions/workflows/maven.yml/badge.svg)](https://github.com/dubasdey/log4j2-jsonevent-layout/actions/workflows/maven.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.dubasdey/log4j2-jsonevent-layout.svg)](https://search.maven.org/artifact/com.github.dubasdey/log4j2-jsonevent-layout)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d964db30361149b797ec3f9b80e5f731)](https://www.codacy.com/gh/dubasdey/log4j2-jsonevent-layout/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=dubasdey/log4j2-jsonevent-layout\u0026amp;utm_campaign=Badge_Grade)\n[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/d964db30361149b797ec3f9b80e5f731)](https://www.codacy.com/gh/dubasdey/log4j2-jsonevent-layout/dashboard?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=dubasdey/log4j2-jsonevent-layout\u0026utm_campaign=Badge_Coverage)\n\n\n\nLog4j2 JSON Event Layout without requirement of thirdparty libraries\n\n## Usage\n\nAdd the `\u003cJSONLog4j2Layout\u003e` tag to any appender to use it.\n\n\n\n**Note:** It could be required to add to the configuration node in the packages attribute the package of the plugin.\n\nExample:\n\n    \u003cConfiguration packages=\"org.erc.log4j2.layout\"\u003e\n\nCheck the Log4j2 configuration java doc for more references \nhttps://logging.apache.org/log4j/2.x/manual/configuration.html\n\n\n### Optional Attributes\n\n* locationInfo - Adds location info to the Trace\n* singleLine - Removes \\r and \\n in JSON String\n* htmlSafe - Escapes additional characters to print the JSON on HTML pages.\n* newLineFormat - Custom new line for each line (if singleLine is off) or the final line (if singleLine is on)\n* plainContextMap - Prints the content of the ContextMap in the root as __key:value__ instead of a contextMap object with the values\n* charset - Charset to use (Default UTF-8)\n* UserField - Collection of user fields with __key__ and __value__ that will be printed in the LogEntry\n\n\n## Result Example\n\nExample expanded to multiple lines\n\n```json\n{\n\"@timestamp\":\"2017-05-03T15:46:34.393Z\",\n\"logger_name\":\"org.dummy.logger\",\n\"level\":\"DEBUG\",\n\"level_int\":500,\n\"thread_name\":\"DummyThread\",\n\"source_host\":\"MYLOCALMACHINE\",\n\"source_ip\":\"192.168.1.10\",\n\"message\":\"Dummy Message Test with tab T\\tT before here.\",\n\"file\":\"File.java\",\n\"line_number\":42,\n\"class\":\"ClassName.class\",\n\"method\":\"MethodElement\",\n\"contextStack\":[\"Entry 1\",\"Entry 2\"],\n\"contextMap\":\n    [\n       {\"X-Generator\":\"JSONLog2j2Layout\"},\n       {\"ThreadContextKey\":\"ThreadContextValue\"}\n    ],\n\"@version\":\"1\"\n}\n```\n\n\n\n\n## Maven dependency\n\nTo include this library in your project just add the dependency to your maven project\n\nExample:\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.dubasdey\u003c/groupId\u003e\n  \u003cartifactId\u003elog4j2-jsonevent-layout\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n## Donate\nBuy me a coffe to help me continue supporting this project. \n\u003ca href=\"https://www.paypal.com/donate/?hosted_button_id=K6DQ5GLE8KHGY\"\u003eBuy me a coffe\u003c/a\u003e\n\n\n\n# Security\n\nYou could check any important security information at the [security document](SECURITY.md)\n\n\n\n# How-Tos\n\n\n### Use the appender formatter to send data to logstash \n\n\n1.- To send to logstash, add the jar to your application classpath and configure a log4j2 socket appender with the host and port used by logstash. Then add to the desired loggers.\n\n```xml\n\u003cSocket name=\"socketAppender\" host=\"myhost\" port=\"9201\"\u003e\n      \u003cJSONLog4j2Layout singleLine=\"true\" /\u003e\n\u003c/Socket\u003e\n```\n\n2.- Configure logstash using tcp input in server mode with the same port.\n\n```\ninput {\n    tcp {\n        port =\u003e 9201\n        mode =\u003e \"server\"\n        codec =\u003e json_lines\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubasdey%2Flog4j2-jsonevent-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdubasdey%2Flog4j2-jsonevent-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdubasdey%2Flog4j2-jsonevent-layout/lists"}