Boost Java Spring Boot Performance with Mica-Log4j2’s Asynchronous Logging
This guide explains how Mica-Log4j2 provides environment‑specific log configurations, high‑throughput asynchronous logging via Disruptor, replaces System.out/err in non‑dev modes, and shows Maven/Gradle dependencies, system settings, custom log levels, file structures, and open‑source resources for Spring Boot applications.
Feature Introduction
Separate log configurations for environments dev, test, ontest, prod.
High‑performance asynchronous logging based on Disruptor.
In non‑dev environments, replace System.out and System.err with log calls to improve performance.
Dependency Coordinates
Maven
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-log4j2</artifactId>
</dependency>Gradle
implementation "net.dreamlu:mica-log4j2"System Configuration
Configuration item LOGGING_PATH defaults to the directory next to the JAR; it specifies the log directory and reads the system environment variable.
Rules
Logs are written to info.log and error.log respectively.
Note: In Spring Boot Admin monitoring, the default displayed file is info.log.
Custom Log Level
logging:
level:
org.xxx.xxx: errorCustom Log Configuration
Place each environment’s log configuration under resources/log:
resources
└── log
├── log4j2_dev.xml
├── log4j2_ontest.xml
├── log4j2_prod.xml
└── log4j2_test.xmlOpen Source Recommendations
Spring Boot microservice toolkit – Mica: https://gitee.com/596392912/mica pig – powerful microservice framework: https://gitee.com/log4j/pig SpringBlade – complete production solution: https://gitee.com/smallc/SpringBlade
Join the “如梦技术” Spring QQ group 479710041 for more information.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
