public class TestLoggerResource
extends org.junit.rules.ExternalResource
Note: If a parent logger is already defined with a less specific log level, then using the
TestLoggerResource can increase the number of log messages received by this logger.
Example: You define a logger for org.apache.runtime with log level INFO and then use TestLoggerResource to listen on org.apache.runtime.feature with log level DEBUG. In this case,
the log output for the parent logger will include DEBUG messages org.apache.runtime.feature.
Implementation note: Make sure to not expose log4j dependencies in the interface of this class to ease updates in logging infrastructure.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
TestLoggerResource.SingleTestResource
SingleTestResource re-uses the code in
TestLoggerResource for try-with-resources
statement. |
| 构造器和说明 |
|---|
TestLoggerResource(Class<?> clazz,
org.slf4j.event.Level level) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
after() |
static TestLoggerResource.SingleTestResource |
asSingleTestResource(String loggerName,
org.slf4j.event.Level level)
Enables the use of
TestLoggerResource for try-with-resources statement. |
protected void |
before() |
List<String> |
getMessages() |
public TestLoggerResource(Class<?> clazz, org.slf4j.event.Level level)
protected void before()
throws Throwable
before 在类中 org.junit.rules.ExternalResourceThrowableprotected void after()
after 在类中 org.junit.rules.ExternalResourcepublic static TestLoggerResource.SingleTestResource asSingleTestResource(String loggerName, org.slf4j.event.Level level) throws Throwable
TestLoggerResource for try-with-resources statement.ThrowableCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.