Spring auto-configuration can be tricky when it comes to conditional based bean creation. The best way to ensure the proper application context is through meticulous testing.
Spring Boot 2.X provides some test helpers for easily configuring an ApplicationContext to simulate auto-configuration test scenarios.
Utility design to run an ApplicationContext and provide AssertJ style assertions. The test is best used as a field of a test class,
Let’s try this with a use case,
Feature Toggling
Let’s assume the application consists of multiple features and these features are toggled ( bean creation ) by environment configuration-based conditions,
Feature Definition
All the features of the application are defined as an enum and the enum contains a code and the application configuration itself. For simplicity let’s consider an app with 3 features.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a monitoring infrastructure building task with some basic matrices. where the metrics are extracted, processed and visualized using the proposed setup to facilitate data-driven decision making.
Specifically, the following metrics were introduced,
Core JVM matrices like CPU, Memory, GC and threads…etc
Monitor any application method execution time
Application Dynamics
Any performance metrics analyzing platform based on following basic steps
Log4j22 provides multiple ways of creating a custom layout for many requirements. This article will explain simple ways to implement custom layouts using log4j2 plugins
In Log4j 2 a plugin is declared by adding a @Plugin annotation to the class declaration. During initialization, the Configuration will invoke the PluginManager to load the built-in Log4j plugins as well as any custom plugins.
We can use both AbstractStringLayout or LogEventPatternConverter according to our requirements. Both options will provide a way to access log4j LogEvent that has all the relevant details about the log event to be customized.