Category Archives: Log4j 2

How to load log4j2 xml file programmatically ?

In this post, We will learn How to load log4j2 xml file programmatically using a demo project? In this example, We have kept our log4j2.xml in the config folder inside the project(instead of keeping log4j2.xml inside src\main\resources). pom.xml We have added log4j2  log4j-api & log4j-core dependency in the dependencies section.

log4j2.xml I have  created log4j2.xml configuration file in the config folder inside… Read More »

Log4j 2 simple example

In this post, We look at Log4j 2 simple example. Log4j2 is the updated version of the popular Apache library. It is used extensively throughout Java applications for so many years. The Apache Log4j 2 carries all the basic logging features of its predecessor and is built with some important improvements, importantly in the area of… Read More »

How to Create a Custom Appender in log4j2 ?

In this post, We will learn How to Create a Custom Appender in log4j 2? In log4j 2, We usually create a plugin for creating a custom appender. When we annotate our custom Appender class with @Plugin(name = “MyCustomAppender”, category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true) the plugin name becomes the configuration element name.… Read More »

Why Logging?

Logging information usually refers to the logging of our application activity that helps in analyzing the runtime behavior of the application especially when our application encounters unexpected behaviors, errors, or tracking steps executed by application flow. As much as you provide logging information. It will be easy to analyze any issues and bugs in the… Read More »