春季启动堆栈溢出与log4j

时间:2019-02-28 08:49:54

标签: java spring-boot gradle log4j2 slf4j

我有一个单元测试,唯一得到的是堆栈溢出,如下所示:

java.lang.StackOverflowError
    at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:125)
    at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
    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)
    at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:37)
    at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger(Log4jLoggerFactory.java:29)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
... many more

我正在尝试使用log4j和slf4j。如果我没有得到关于将log4j上下文转换为slf4j上下文的不同错误,则排除了logback。

我已将build.gradle文件减少到最小依赖度:

testCompile ('org.springframework.boot:spring-boot-starter-test'){
    exclude group: 'ch.qos.logback', module: 'logback-classic'
}
testCompile 'com.fedex.gss.extras:gss-extras-base'
testCompile 'org.mockito:mockito-core'
testCompile('junit:junit')

还要导入log4j和springboot的BOM。

有什么想法吗?

非常感谢。

0 个答案:

没有答案