Extensible Log4j2 JSON Layout

Extend Log4j2 JSON layout with custom fields

License

License

Categories

Categories

JSON Data
GroupId

GroupId

org.crosslibs
ArtifactId

ArtifactId

extensible-json-layout
Last Version

Last Version

2.9.0
Release Date

Release Date

Type

Type

jar
Description

Description

Extensible Log4j2 JSON Layout
Extend Log4j2 JSON layout with custom fields
Project URL

Project URL

https://github.com/cpdevws/extensible-json-layout
Source Code Management

Source Code Management

https://github.com/cpdevws/extensible-json-layout/tree/master

Download extensible-json-layout

How to add to project

<!-- https://jarcasting.com/artifacts/org.crosslibs/extensible-json-layout/ -->
<dependency>
    <groupId>org.crosslibs</groupId>
    <artifactId>extensible-json-layout</artifactId>
    <version>2.9.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.crosslibs/extensible-json-layout/
implementation 'org.crosslibs:extensible-json-layout:2.9.0'
// https://jarcasting.com/artifacts/org.crosslibs/extensible-json-layout/
implementation ("org.crosslibs:extensible-json-layout:2.9.0")
'org.crosslibs:extensible-json-layout:jar:2.9.0'
<dependency org="org.crosslibs" name="extensible-json-layout" rev="2.9.0">
  <artifact name="extensible-json-layout" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.crosslibs', module='extensible-json-layout', version='2.9.0')
)
libraryDependencies += "org.crosslibs" % "extensible-json-layout" % "2.9.0"
[org.crosslibs/extensible-json-layout "2.9.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.logging.log4j : log4j jar 2.9.0
org.apache.logging.log4j : log4j-api jar 2.9.0
org.apache.logging.log4j : log4j-core jar 2.9.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.1

test (3)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-api jar 2.9.0
org.apache.logging.log4j : log4j-core jar 2.9.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Extensible Log4j2 Json Layout

Build Status

Extensible Log4j2 JSON Layout (extensible-json-layout) provides the ability to add custom attributes to the JSON logs.

How to use

In your log4j2 configuration file (log4j2.xml, log4j2.yml, log4j2.yaml or log4j2.json), please use ExtensibleJsonLayout instead of JsonLayout. Please note that all configuration properties of JsonLayout are supported by ExtensibleJsonLayout.

In addition, you may inject custom JSON properties into your code by passing the configuration property adapter in <ExtensibleJsonLayout />

1. Example log4j2.xml snippet with configuration set to defaults:
    <Appenders>
        <Console name="Console-Appender" target="SYSTEM_OUT">
            <ExtensibleJsonLayout />
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
2. Example log4j2.xml snippet with custom log adapter:
    <Appenders>
        <Console name="Console-Appender" target="SYSTEM_OUT">
            <ExtensibleJsonLayout adapter="org.crosslibs.extensible.json.layout.Adapter" />
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>

Build Configuration

Gradle

If you are using gradle, please include the following snippet into your build.gradle file

buildScript {
    ext {
        log4j2Version = '2.9.0'
    }
}

dependencies {
  compile group: 'org.crosslibs', artifact: 'extensible-json-layout', version: log4jVersion
}

Maven

If you are using maven, please include the following snippet into your pom.xml file

<properties>
    <log4j2.version>2.9.0</log4j2.version>
</properties>

<dependency>
    <groupId>org.crosslibs</groupId>
    <arifactId>extensible-json-layout</artifactId>
    <version>${log4j2.version}</version>
</dependency>

Contact

In case of any questions or feedback, please reach out to Chaitanya Prakash N or log an issue.

Pull requests welcome.

Versions

Version
2.9.0