Java Code Examples for org.slf4j.Logger.isInfoEnabled()

The following are Jave code examples for showing how to use isInfoEnabled() of the org.slf4j.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: angel   File: ReflectionUtils.java   View Source Code Vote up 6 votes
public static void logThreadInfo(Logger log, String title, long minInterval) {
  boolean dumpStack = false;
  if (log.isInfoEnabled()) {
    synchronized (ReflectionUtils.class) {
      long now = System.currentTimeMillis();
      if (now - previousLogTime >= minInterval * 1000L) {
        previousLogTime = now;
        dumpStack = true;
      }
    }
    if (dumpStack) {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      printThreadInfo(new PrintWriter(buffer), title);
      log.info(buffer.toString());
    }
  }
}
 
Example 2
Project: OftenPorter   File: PortExecutor.java   View Source Code Vote up 6 votes
private void responseObject(WObject wObject, PorterOfFun porterOfFun, Object object, boolean nullClose)
{
    if (object != null)
    {
        Logger LOGGER = logger(wObject);

        if (object != null && object instanceof JResponse && ((JResponse) object).isNotSuccess())
        {
            wObject.getResponse().toErr();
            if (LOGGER.isDebugEnabled())
            {
                LOGGER.debug("{}:{}", wObject.url(), object);

            } else if (LOGGER.isInfoEnabled())
            {
                LOGGER.info("{}:{}", wObject.url(), object);
            }
        }
        doFinalWrite(wObject, porterOfFun, object);
        close(wObject);
    } else if (nullClose)
    {
        close(wObject);
    }
}
 
Example 3
Project: spring-i18n-support   File: AbstractDaoMessageSource.java   View Source Code Vote up 6 votes
/**
 * Writes an exception log.
 *
 * @param code   message code involved
 * @param locale the locale involved
 * @param ex     the exception to log
 * @param logger the logger to log to
 */
protected void logException(String code,
		Locale locale,
		Exception ex,
		Logger logger) {
	if (logger.isInfoEnabled()) {
		StringBuilder sb = new StringBuilder();
		sb.append("FAILED: resolveCode [");
		sb.append(code);
		sb.append("] for language [");
		sb.append(locale.toString());
		sb.append("] because of: ");
		sb.append(ex.getClass().getName());
		sb.append("Message:");
		sb.append(ex.getMessage() != null ? ex.getMessage().replaceAll("\n", " ") : "null");
		logger.info(sb.toString());
	}
}
 
Example 4
Project: otter-G   File: LogInterceptor.java   View Source Code Vote up 6 votes
/**
 * 记录请求信息
 * 
 * @param methodInvocation
 * @param take
 */
private void dump(MethodInvocation methodInvocation, Object result, long take) {
    // 取得日志打印对象
    Logger log = getLogger(methodInvocation.getMethod().getDeclaringClass());
    Object[] args = methodInvocation.getArguments();
    StringBuffer buffer = getArgsString(args);

    if (log.isInfoEnabled()) {
        String className = ClassUtils.getShortClassName(methodInvocation.getMethod().getDeclaringClass());
        String methodName = methodInvocation.getMethod().getName();
        String resultStr = getResultString(result);

        String now = new SimpleDateFormat(DATA_FORMAT).format(new Date());
        log.info(MessageFormat.format(MESSAGE, new Object[] { className, methodName, now, take, buffer.toString(),
                resultStr }));
    }
}
 
Example 5
Project: easyhbase   File: LoggerUtils.java   View Source Code Vote up 6 votes
public static int getLoggerLevel(Logger logger) {
    if (logger == null) {
        throw new NullPointerException("logger must not be null");
    }
    if (logger.isTraceEnabled()) {
        return TRACE_LEVEL;
    }
    if (logger.isDebugEnabled()) {
        return DEBUG_LEVEL;
    }
    if (logger.isInfoEnabled()) {
        return INFO_LEVEL;
    }
    if (logger.isWarnEnabled()) {
        return WARN_LEVEL;
    }
    if (logger.isErrorEnabled()) {
        return ERROR_LEVEL;
    }
    return DISABLE_LEVEL;
}
 
Example 6
Project: chimera   File: ChimeraLogListener.java   View Source Code Vote up 5 votes
@Override
public LogEvent log(LogEvent ev)
{
    final String clsName = ev.getRealm().replace('/', ':');
    Logger logger = LoggerFactory.getLogger(prefix == null ? clsName : prefix + "." + clsName);

    if (logger.isInfoEnabled())
    {
        ByteArrayOutputStream w = new ByteArrayOutputStream();
        PrintStream p = new PrintStream(w);
        ev.dump(p, "");
        logger.info("| \n" + (w.toString().trim()));
    }
    return ev;
}
 
Example 7
Project: slf4j-lambda   File: LambdaLoggerUtils.java   View Source Code Vote up 5 votes
/**
 * check if log level is enabled in the underlying logger
 *
 * @param underlyingLogger real Slf4j Logger implementation
 * @param logLevel log level
 * @param marker marker
 * @return true if log level is enabled or false.
 */
public static boolean isLogLevelEnabled(Logger underlyingLogger, Level logLevel, Marker marker) {
    switch (logLevel) {
        case TRACE:
            if (marker == null) {
                return underlyingLogger.isTraceEnabled();
            }
            return underlyingLogger.isTraceEnabled(marker);
        case DEBUG:
            if (marker == null) {
                return underlyingLogger.isDebugEnabled();
            }
            return underlyingLogger.isDebugEnabled(marker);
        case INFO:
            if (marker == null) {
                return underlyingLogger.isInfoEnabled();
            }
            return underlyingLogger.isInfoEnabled(marker);
        case WARN:
            if (marker == null) {
                return underlyingLogger.isWarnEnabled();
            }
            return underlyingLogger.isWarnEnabled(marker);
        case ERROR:
            if (marker == null) {
                return underlyingLogger.isErrorEnabled();
            }
            return underlyingLogger.isErrorEnabled(marker);
        default:
            break;
    }
    return false;
}
 
Example 8
Project: mzzb-server   File: SecurityConfig.java   View Source Code Vote up 5 votes
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
            .antMatchers("/api/users/**").hasRole("ADMIN")
            .antMatchers("/api/session").permitAll()
            .antMatchers(HttpMethod.GET).permitAll()
            .antMatchers("/api/**").hasRole("BASIC");

    http.addFilterAfter(new CsrfTokenResponseHeaderBindingFilter(), CsrfFilter.class);

    Logger logger = LoggerFactory.getLogger(getClass());
    if (logger.isInfoEnabled()) {
        logger.info("设置安全策略");
    }
}
 
Example 9
Project: mzzb-server   File: AutoRunConfig.java   View Source Code Vote up 5 votes
private void fetchSakuraSpeedData(int retry) {
    Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
    if (retry == 0) {
        if (logger.isWarnEnabled()) {
            logger.warn("fetching sakura speed data failed");
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("fetching sakura speed data ({})", retry);
        }
        try {
            sakuraSpeedSpider.fetch();
        } catch (IOException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("fetching sakura speed data throw an error", e);
            }
            if (retry > 0) {
                fetchSakuraSpeedData(retry - 1);
            } else {
                return;
            }
        }
        if (logger.isInfoEnabled()) {
            logger.info("fetched sakura speed data ({})", retry);
        }
    }
}
 
Example 10
Project: mzzb-server   File: AutoRunConfig.java   View Source Code Vote up 5 votes
private void fetchAmazonDiscsData(int retry) {
    Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
    if (retry == 0) {
        if (logger.isWarnEnabled()) {
            logger.warn("fetching amazon discs data failed");
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("fetching amazon discs data ({})", retry);
        }
        try {
            amazonDiscsSpider.fetch();
        } catch (IOException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("fetching amazon discs data throw an error", e);
            }
            if (retry > 0) {
                fetchSakuraSpeedData(retry - 1);
            } else {
                return;
            }
        }
        if (logger.isInfoEnabled()) {
            logger.info("fetched amazon discs data ({})", retry);
        }
    }
}
 
Example 11
Project: ait-platform   File: AitLogger.java   View Source Code Vote up 5 votes
/**
 * info
 * @param logger
 * @param message
 * @param params
 */

public static void info(Logger logger, String message, Object... params) {
	
	if (logger.isInfoEnabled()) {
		logger.info(message, params);
	}
}
 
Example 12
Project: Tenable.io-SDK-for-Java   File: LoggerHelper.java   View Source Code Vote up 5 votes
public static LogLevel getLogLevel( Logger logger ) {
    if( logger.isTraceEnabled() )
        return LogLevel.TRACE;
    else if( logger.isDebugEnabled() )
        return LogLevel.DEBUG;
    else if( logger.isInfoEnabled() )
        return LogLevel.INFO;
    else if( logger.isWarnEnabled() )
        return LogLevel.WARN;
    else if( logger.isErrorEnabled() )
        return LogLevel.ERROR;

    return LogLevel.NONE;
}
 
Example 13
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger,String format,Supplier<Object> supplier){
    if(logger.isInfoEnabled()){
        logger.info(format,supplier.get());
    }
}
 
Example 14
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger,Supplier<Object> supplier){
    if(logger.isInfoEnabled()){
        logger.info(Objects.toString(supplier.get()));
    }
}
 
Example 15
Project: soabase-stages   File: Slf4JTracing.java   View Source Code Vote up 4 votes
@Override
public boolean enabled(Logger logger) {
    return logger.isInfoEnabled();
}
 
Example 16
Project: centraldogma   File: Polyfills.java   View Source Code Vote up 4 votes
public static void consoleInfo(Logger logger, ScriptObjectMirror args) {
    if (logger.isInfoEnabled()) {
        logger.info(logMessage(args));
    }
}
 
Example 17
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isInfoEnabled()) {
        logger.info(format, supplier.get());
    }
}
 
Example 18
Project: happylifeplat-tcc   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger, Supplier<Object> supplier) {
    if (logger.isInfoEnabled()) {
        logger.info(Objects.toString(supplier.get()));
    }
}
 
Example 19
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isInfoEnabled()) {
        logger.info(format, supplier.get());
    }
}
 
Example 20
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void info(Logger logger, Supplier<Object> supplier) {
    if (logger.isInfoEnabled()) {
        logger.info(Objects.toString(supplier.get()));
    }
}