Apache Log4j
Features
Below, we share some highlights from Log4j features.
- Batteries included
Log4j bundles a rich set of components to assist various use cases.
Appenders targeting files, network sockets, databases, SMTP servers, etc.
Layouts that can render CSV, HTML, JSON, Syslog, etc. formatted outputs
Filters based on log event rates, regular expressions, scripts, time, etc.
Lookups for accessing system properties, environment variables, log event fields, etc.
- Reliability
Log4j is built with solid reliability in mind.It can automatically reload its configuration upon modification and will do so without losing log events while reconfiguration occurs.
- Performance
When configured correctly, Log4j can deliver excelling performance without almost any burden on the Java garbage collector, and it will do so without sacrificing reliability.Check out thePerformance page for details.
- Extensibility
Log4j contains a fully-fledgedplugin support that users can leverage to extend functionality.You can easily add your components (layouts, appenders, filters, etc.) or customize existing ones (e.g., adding new directives toPattern Layout orJSON Template Layout).Check out theExtending Log4j page.
- Powerful API
Log4j is a logging system where the API (called Log4j API) and its implementation (called Log4j Core) is distinctly separate from each other.Log4j API provides the most feature-rich logging facade in the market; support for various
Messagetypes (such asObjectorMap) besides plainString, lambda expressions, parameterized logging, markers, levels, diagnostic contexts (aka. MDC/NDC), etc.Log4j team takes backward compatibility very seriously and makes sure people relying on Log4j API gets a logging facade that is straightforward to use in a correct and future-proof way.Check out theJava API,Kotlin APIandScala APIpages for further information.- No vendor lock-in
Log4j API is a generic logging facade for various logging frameworks.While Log4j Core implements it at its fullest, you can easily switch to other implementations such as Logback or JUL (
java.util.logging).