Main Modules in Apache Log4j

Q

What are main modules in Apache Log4j? I want to know which modules and their JAR files should I use with my Java Application.

✍: FYIcenter.com

A

Apache Log4j is divided into a number of modules. And each component has 3 JAR files: Bytecode JAR, Source Code JAR and Java Doc JAR. They are all included in the Apache Log4j binary package.

In most cases, you only need to include Bytecode JAR files of two modules: API and Core. For example, log4j-api-2.14.1.jar and log4j-core-2.14.1.jar are required in your Java classpath to run most applications.

Here are main modules in Apach Log4j:

  • Log4j API (Required, JAR example: log4j-api-2.14.1.jar) - Provides the interface that applications should code to and provides the adapter components required for implementers to create a logging implementation.
  • Log4j Implementation (Required, JAR example: log4j-core-2.14.1.jar) - Provides the functional components of the logging system. Users are free to create their own plugins and include them in the logging configuration.
  • Log4j IOStreams (Optional, JAR example: log4j-iostreams-2.14.1.jar) - Is a Log4j API extension that provides numerous classes from java.io that can either write to a Logger while writing to another OutputStream or Writer, or the contents read by an InputStream or Reader can be wiretapped by a Logger.
  • Commons Logging Bridge (Optional, JAR example: log4j-jcl-2.14.1.jar) - Allows applications coded to the Commons Logging API to use Log4j 2 as the implementation.
  • JDK Logging Adapter (Optional, JAR example: log4j-jul-2.14.1.jar) - Is a custom implementation of java.util.logging.LogManager that uses Log4j. This adapter can be used with either the Log4j API or Log4j Core.
  • Flume Appender (Optional, JAR example: log4j-flume-ng-2.14.1.jar) - Allows applications to send events to Flume Agents.
  • Log4j 1.2 Bridge (Optional, JAR example: log4j-1.2-api-2.14.1.jar) - Allows applications coded to use Log4j 1.2 API to use Log4j 2 instead.
  • Log4j 2 SLF4J Binding (Optional, JAR example: log4j-slf4j-impl-2.14.1.jar) - Allows applications coded to the SLF4J API to use Log4j 2 as the implementation.
  • Log4j 2 SLF4J 1.8 Binding (Optional, JAR example: log4j-slf4j18-impl-2.14.1.jar) - Allows applications coded to the SLF4J 1.8 API to use Log4j 2 as the implementation.
  • Log4j 2 to SLF4J Adapter (Optional, JAR example: log4j-to-slf4j-2.14.1.jar) - Allows applications coded to the Log4j 2 API to be routed to SLF4J. Use of this adapter may cause some loss of performance as the Log4j 2 Messages must be formatted before they can be passed to SLF4J.
  • Log4j JMX GUI (Optional, JAR example: log4j-jmx-gui-2.14.1.jar) - Provides a Swing-based client for remotely editing the log4j configuration and remotely monitoring StatusLogger output.
  • Log4j Tag Library (Optional, JAR example: log4j-taglib-2.14.1.jar) - Creates the capability of inserting log statements in JSPs without the use of Java scripting.
  • Web Servlet Containers (Optional, JAR example: log4j-web-2.14.1.jar) - Provides support for automatically enabling Log4j in Servlet containers.
  • NoSQL Appenders (Optional, JAR example: log4j-nosql-2.12.1.jar) - Allow applications to send events to NoSQL repositories. To use it, you need both the log4j-nosql as well as the appropriate driver for your NoSQL database type. NoSQL Appender JAR file is removed from Log4j packages now and combined with the actual NoSQL driver JAR file, like log4j-couchdb-2.14.1.jar.
  • Application Server (Optional, JAR example: log4j-appserver-2.14.1.jar) - Provides support for integrating Log4j into various Java Application Servers, including Apache Tomcat.
  • Cassandra Appenders (Optional, JAR example: log4j-cassandra-2.14.1.jar) - Datastax Cassandra driver and Log4j Cassandra library.
  • CouchDB (Optional, JAR example: log4j-couchdb-2.14.1.jar) - LightCouch CouchDB client library and Log4j CouchDB library.
  • Docker (Optional, JAR example: log4j-docker-2.14.1.jar) - Allow applications to use Log4j in Docker environment.
  • JPA Appender (Optional, JAR example: log4j-jpa-2.14.1.jar) - The Java Persistence API classes, a JPA provider implementation, and a decorated entity that the user implements.
  • Liquibase Binding (Optional, JAR example: log4j-liquibase-2.14.1.jar) - Enables Liquibase to log via Log4j.
  • MongoDB 3 Appender (Optional, JAR example: log4j-mongodb3-2.14.1.jar) - Allows applications to send log messages to MongoDB 3.
  • MongoDB 4 Appender (Optional, JAR example: log4j-mongodb4-2.14.1.jar) - Allows applications to send log messages to MongoDB 4.
  • JDBC Appender (Optional, JAR example: log4j-jdbc-dbcp2-2.14.1.jar) - Allows applications to send log messages to database using JDBC and DBCP (Database Connection Pools).
  • Spring Boot (Optional, JAR example: log4j-spring-boot-2.14.1.jar) - Enhanced support for Spring Boot beyond what Spring Boot itself provides.
  • Spring Cloud Config Client (Optional, JAR example: log4j-spring-cloud-config-client-2.14.1.jar) - Spring Cloud Bus is required if notification of logging configuration changes is desired. Spring Boot is required but applications do not have to be packaged as a Spring Boot application.

 

⇒ Difference Between Apache Log4j 2.x and 1.x

⇐ Main Features of Apache Log4j

⇑ Introduction to Apache Log4j

⇑⇑ FAQ for Apache Log4j

2015-11-07, 3278👍, 0💬