8000 GitHub - WildBeavers/log4j12-json-layout: Support JSON logging for log4j version 1.2
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WildBeavers/log4j12-json-layout

Repository files navigation

log4j12-json-layout

A JSON layout for Log4J (v1.2). This project is based on the GitHub project thmshmm/log4j-json-layout but uses more recent version of Java, Maven and dependent libraries.

Output format

{"timestamp":"<DATE>","level":"<LEVEL>","logger":"<LOGGER>","thread":"<THREAD>","message":"<MESSAGE>","stacktrace":"<STACKTRACE>"}

The "stacktrace" item is optional and will only be in the JSON object if the log message has a trace message.

Example log4j.properties

log4j.appender.myAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.myAppender.File=/var/log/my.log
log4j.appender.myAppender.layout=com.github.wildbeavers.log4j12jsonlayout.JsonLayout
log4j.appender.myAppender.layout.DatePattern=yyyy-MM-dd HH:mm:ss,SSS

Layout configuration

Name Options Default
DatePattern all valid SimpleDateFormat patterns yyyy-MM-dd HH:mm:ss,SSS

Design Decisions

  • JSON parser: FasterXML/jackson-core
    This project has been created for supporting JSON logging for Kafka and ZooKeeper. Both projects already contain the required libraries.
  • JAVA Version: 8
    • a long supported Java version has to be selected => LTS version required
    • a recent but not bleeding edge version is required
    • a version which can be used by legacy enterprise applications is required

Building

  1. The pom.xml contains at the beginning a list of properties with the versions of the dependent libraries. Update these values to match with the Kafka / ZooKeeper version (always choose the smaller version when they are different)

  2. Local build:

        mvn package
    
  3. Release build

    1. Update version at pom.xml

    2. Build JAR inside a Docker container

      docker build . -t log4j12-json-layout:latest
      
    3. Copy the JAR to the local filesystem:

      docker run -v ${PWD}:/local log4j12-json-layout:latest bash -c "cp /target/log4j12-json-layout-*.jar /local/ && chmod ugo+w /local/*"
      
    4. Create new release at Github and attach JAR

Similar projects

There are several projects with a similar scope:

About

Support JSON logging for log4j version 1.2

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0