public final class LogCaptor extends Object implements AutoCloseable
| Modifier and Type | Method and Description |
|---|---|
void |
addFilter(ch.qos.logback.core.filter.Filter<ch.qos.logback.classic.spi.ILoggingEvent> filter) |
void |
clearLogs() |
void |
close() |
void |
disableConsoleOutput()
Disables the output of the log entries to the console.
|
void |
disableLogs()
Overrides the log level property of the target logger.
|
void |
enableConsoleOutput()
The output of the log entries to the console are enabled by default but can be re-enabled if
they are disabled earlier by
disableConsoleOutput() |
static LogCaptor |
forClass(Class<?> clazz)
Captures log messages for the provided class
|
static LogCaptor |
forName(String name)
Captures log messages for the provided logger name
|
static LogCaptor |
forRoot()
Captures all log messages
|
List<String> |
getDebugLogs() |
List<String> |
getErrorLogs() |
List<String> |
getInfoLogs() |
List<LogEvent> |
getLogEvents() |
List<String> |
getLogs() |
List<String> |
getTraceLogs() |
List<String> |
getWarnLogs() |
void |
resetLogLevel()
Resets the log level of the target logger to the initial value which was available before
changing it with
setLogLevelToInfo(), setLogLevelToDebug() or with setLogLevelToTrace() |
void |
setLogLevelToDebug()
Overrides the log level property of the target logger.
|
void |
setLogLevelToInfo()
Overrides the log level property of the target logger.
|
void |
setLogLevelToTrace()
Overrides the log level property of the target logger.
|
public static LogCaptor forRoot()
public static LogCaptor forClass(Class<?> clazz)
clazz - Class for capturingpublic static LogCaptor forName(String name)
name - Logger name for capturingpublic void addFilter(ch.qos.logback.core.filter.Filter<ch.qos.logback.classic.spi.ILoggingEvent> filter)
public void setLogLevelToInfo()
LogCaptor has been created.
To roll-back to the initial state use: resetLogLevel()
This option will implicitly include the following log levels: WARN and ERRORpublic void setLogLevelToDebug()
LogCaptor has been created.
To roll-back to the initial state use: resetLogLevel()
This option will implicitly include the following log levels: INFO, WARN and ERRORpublic void setLogLevelToTrace()
LogCaptor has been created.
To roll-back to the initial state use: resetLogLevel()
This option will implicitly include the following log levels: INFO, DEBUG, WARN and ERRORpublic void disableLogs()
LogCaptor has been created.
To roll-back to the initial state use: resetLogLevel()public void disableConsoleOutput()
enableConsoleOutput().
LogCaptor will still be capturing the log entries.public void enableConsoleOutput()
disableConsoleOutput()public void resetLogLevel()
setLogLevelToInfo(), setLogLevelToDebug() or with setLogLevelToTrace()public void clearLogs()
public void close()
close in interface AutoCloseableCopyright © 2023. All rights reserved.