Java slf4j Logger logError(final Logger logger, final String message, final Throwable cause)

Here you can find the source of logError(final Logger logger, final String message, final Throwable cause)

Description

IntelliJ bubbles up all error level logging to user, and if there is a "cause", it makes it a clickable link and user can view the stacktrace.

License

Open Source License

Parameter

Parameter Description
logger the logger to use
message the message to display
cause the chained exception

Declaration

public static void logError(final Logger logger, final String message, final Throwable cause) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See License.txt in the project root.

import org.slf4j.Logger;

public class Main {
    /**//from w  ww  .j  ava 2 s .  c om
     * IntelliJ bubbles up all error level logging to user, and if there is a "cause", it makes it a clickable link
     * and user can view the stacktrace.
     *
     * However, IntelliJ also exposes an button to disable this plugin on the stacktrace viewer, which is not
     * desirable, so in this case we just log the error message, but show the cause in a warning log
     *
     * @param logger the logger to use
     * @param message the message to display
     * @param cause the chained exception
     */
    public static void logError(final Logger logger, final String message, final Throwable cause) {
        logger.error(message);
        //weird thing we are doing for IntelliJ
        logger.warn(message, cause);
    }
}

Related

  1. logBind(Logger log, int index, Object value)
  2. logBytes(byte[] data, int length, String prefix, Logger logger)
  3. logDebug(Logger logger, String mensagem, Object... params)
  4. logDebug(String string)
  5. logEntrance(Logger logger, String methodName, String methodArguments)
  6. logError(Logger log, Throwable t, String message)
  7. logError(String message, Throwable ex, Logger logger, String userId)
  8. logErrors(Logger logger, List strings)
  9. LogException(Logger log, String descrption, Throwable e)