After log4j2 is configured in build.gradle, bootRun starts the project and throws the following exception:

Exception in thread "main" java.lang.StackOverflowError
	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
...
Copy the code

Log4j2 conflicts with log4j in the spring-boot-starter-logging module:

In build.gradle, exclude spring-boot-starter-logging:

Configurations {// Exclude the default log compile. Exclude module:'spring-boot-starter-logging'
}
Copy the code