How to configure log4j.properties for SpringJUnit4ClassRunner?

后端 未结 7 641
深忆病人
深忆病人 2021-01-30 04:06

Suddenly this keeps happening during a JUnit test. Everything was working, I wrote some new tests and this error occured. If I revert it, it won\'t go away. Why is that?

相关标签:
7条回答
  • 2021-01-30 04:43

    Add a log4j.properties(log4j.xml) file with at least one appender in root of your classpath.

    The contents of the file(log4j.properties) can be as simple as

    log4j.rootLogger=WARN,A1
    
    # A1 is set to be a ConsoleAppender.
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c %x - %m%n
    

    This will enable log4j logging with default log level as WARN and use the java console to log the messages.

    0 讨论(0)
提交回复
热议问题