How to solve java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY

When deploying applications on WildFly, encountering a log4j2 core libs and log4j2 API mismatch issue is not uncommon. This issue, presented as java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY, arises due to discrepancies between the Log4j2 core libraries used within the application and the Log4j2 API provided by WildFly’s modules. Cause: Firstly, the mismatch occurs when the application uses a … Read more

How to configure Logging Profiles in WildFly

A logging profile allows you to define and configure logging specific to that particular application. This includes specifying the log levels, log handlers, and formatting for the logs generated by your application. In this article we will learn how to define a Logging Profile and the key differences with Standard Loggers.

Read more

Solving “SLF4J: Failed to load class ‘org.slf4j.impl.StaticLoggerBinder'” Error

The error message “SLF4J: Failed to load class ‘org.slf4j.impl.StaticLoggerBinder‘” commonly occurs in Java applications when the Simple Logging Facade for Java (SLF4J) framework cannot find an appropriate implementation for the logging system. This error can be frustrating, but it’s relatively straightforward to resolve by adding the necessary SLF4J dependencies to your project. In this tutorial, we’ll walk you through the steps to fix this error.

Read more

How to print logs in JSON format in WildFly

This article discusses the configuration you can apply in WildFly to enable logging in JSON format. We will learn how to do that natively in WildFly or using a Log4j custom configuration. Strategies for logging in JSON There are several use cases in which logging in JSON format can be useful. For example: Use cases … Read more

How to compress logs in WildFly

This article shows how to enable logs compression in WildFly by setting the appropriate suffix in your Periodic Rotating File Handler. In the second part of this tutorial we will learn how to compress logs using Log4j instead.

Read more

How to configure SLF4J in WildFly applications

In this tutorial, we will discuss how to use Simple Logging Facade for Java (SLF4J) with Wildfly application server. SLF4J is a logging facade that provides a unified interface for various logging frameworks, such as log4j, java.util.logging, and Logback. It allows for the decoupling of the application code from the underlying logging framework, making it easier to change the logging framework without modifying the application code.

Read more

Getting Started with Simple Logging Facade (SLF4J)

Simple Logging Facade for Java (SLF4J) is a logging facade that provides a unified interface for various logging frameworks, such as log4j, java.util.logging, and Logback. It allows for the decoupling of the application code from the underlying logging framework, making it easier to change the logging framework without modifying the application code. Here is a small tutorial to discuss the advantages of using SLF4J versus direct logging configuration.

Read more