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

voidsleepMs(Logger logger, long timeMs)
Sleeps for the given number of milliseconds, reporting interruptions using the given logger.
sleepMs(logger, timeMs, false);
voidstacktrace(Logger log, Throwable t)
Print the stacktrace to the log.
try {
    if (log.isDebugEnabled()) {
        if (t != null) {
            log.debug("*****************************<<stacktrace>>*******************************");
            log.debug(t.getLocalizedMessage());
            StackTraceElement[] ste = t.getStackTrace();
            if (ste != null && ste.length > 0) {
                for (StackTraceElement st : ste) {
...
voidstartTestLogging(String name)
Adds the test name to MDC so that sift appender can use it and log the new log events to a different file
MDC.put(TEST_NAME, name);
StringstopTestLogging()
Removes the key (log file name) from MDC
String name = MDC.get(TEST_NAME);
MDC.remove(TEST_NAME);
return name;
StringstringifyStackTrace(Exception e)
A helper method that converts an Exception event's StackTrace to a String (since this didn't seem easily available in org.slf4j.Logger)
return e.toString(); 
voidtestLogError(String errorMessage, Exception ex)
test Log Error
if (testLog != null) {
    testLog.error(errorMessage);
if (isPrintStackTrace && ex != null && testLog != null) {
    testLog.error(ex.getMessage(), ex);
voidtraceCall(Class objectClass)
trace Call
Logger log = LoggerFactory.getLogger(objectClass);
traceCall(log, 3);
voidtraceLog(final Logger log, final String logMethodName, String logMsg)
TODO
traceLog(log, logMethodName, logMsg, null);
voidwarn(Logger log, Object... args)
warn
if (log.isWarnEnabled()) {
    StringBuilder sb = new StringBuilder();
    for (Object o : args) {
        sb.append(o).append(", ");
    log.warn(sb.toString());
voidwarn(String format, Object... arguments)
warn
warn(innerGet(), format, arguments);