Annotation Type LogOnFailure
-
@ExtendWith(com.github.robtimus.junit.support.extension.logging.LogOnFailureExtension.class) @Target({FIELD,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface LogOnFailure
LogOnFailure
can be used to suppress logging. However, if a test fails, all logging that had been suppressed will occur at the end of the failed test.To suppress logging, add a logger field (static or not) to your test class and annotate it with
LogOnFailure
. The following types of loggers are supported:Logger
, usually created usingLogManager.getLogger(String)
.Logger
(from Log4j 2), usually created usingLogManager.getLogger(String)
orLogManager.getLogger(Class)
. Note that this requireslog4j-core
as implementation.Logger
(from reload4j or Log4j 1.x), usually created usingLogger.getLogger(String)
orLogger.getLogger(Class)
.Logger
(from logback), usually created usingLoggerFactory.getLogger(String)
orLoggerFactory.getLogger(Class)
. Note that this requireslogback
as single SLF4J implementation.
- Author:
- Rob Spoor
- Since:
- 3.0