Java Utililty Methods slf4j Logger

List of utility methods to do slf4j Logger

Description

The list of methods to do slf4j Logger are organized into topic(s).

Method

voidalarm(String string)
alarm
alarm.info(string);
voidcallShell(final String shellString, final Logger log)
call Shell
Process process = null;
try {
    String[] cmdArray = splitShellString(shellString);
    process = Runtime.getRuntime().exec(cmdArray);
    process.waitFor();
    log.info("callShell: <{}> OK", shellString);
} catch (Throwable e) {
    log.error("callShell: readLine IOException, " + shellString, e);
...
voidcaught(Exception e, String... bizDesc)
caught
if (null == e) {
    return;
LOGGER.error(buildDesc(bizDesc), e);
voidcheckInterrupted(String type, String name, Logger logger)
check Interrupted
if (Thread.currentThread().isInterrupted()) {
    logger.error(type + "[" + name + "] interrupted.");
    throw new InterruptedException(type + "[" + name + "] interrupted.");
voidcleanLoggingMdc()
clean Logging Mdc
org.slf4j.MDC.remove(MDC_TEST_ID_KEY);
voidclearRequestId()
Clear the request ID.
MDC.remove(REQUEST_KEY);
MDC.remove(REQUEST_ID_KEY);
voidclose(final AutoCloseable closeable, final Logger log)
Attempt to close the specified closeable and log any eventual error.
if (closeable != null) {
    try {
        closeable.close();
    } catch (Exception e) {
        if (log != null) {
            String s = "unable to close stream/reader/writer: " + getMessage(e);
            if (log.isDebugEnabled())
                log.debug(s, e);
...
voidcloseQuietly(AutoCloseable toClose, Logger log)
close Quietly
if (toClose != null) {
    try {
        toClose.close();
    } catch (Exception e) {
        log.debug("Exception during close {}", e);
voidconfigureXWikiLogs()
If running under Maven 3.1+, where slf4j-simple is used as the logging backend, configure the SLF4J simple to have proper logging levels that do not generate too many logs.
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", WARN_LEVEL);
System.setProperty("org.slf4j.simpleLogger.log.org", WARN_LEVEL);
System.setProperty("org.slf4j.simpleLogger.log.org.xwiki", INFO_LEVEL);
System.setProperty("org.slf4j.simpleLogger.log.hsqldb", WARN_LEVEL);
System.setProperty("org.slf4j.simpleLogger.log.org.xwiki.logging.logback", ERROR_LEVEL);
voidconfigureXWikiLogs()
If running under Maven 3.1+, where slf4j-simple is used as the logging backend, configure the system so that logs generated by XWiki or Hibernate follow the Maven logging settings.
String rootLogLevel = System.getProperty("org.slf4j.simpleLogger.defaultLogLevel");
if (rootLogLevel == null) {
    return;
String logLevel;
switch (rootLogLevel) {
case DEBUG_LEVEL:
case ERROR_LEVEL:
...