本文整理匯總了Java中org.slf4j.Logger.isInfoEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.isInfoEnabled方法的具體用法?Java Logger.isInfoEnabled怎麽用?Java Logger.isInfoEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.slf4j.Logger
的用法示例。
在下文中一共展示了Logger.isInfoEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: logThreadInfo
import org.slf4j.Logger; //導入方法依賴的package包/類
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());
}
}
}
示例2: responseObject
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
示例3: logException
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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());
}
}
示例4: dump
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 記錄請求信息
*
* @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 }));
}
}
示例5: getLoggerLevel
import org.slf4j.Logger; //導入方法依賴的package包/類
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;
}
示例6: log
import org.slf4j.Logger; //導入方法依賴的package包/類
@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;
}
示例7: isLogLevelEnabled
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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;
}
示例8: configure
import org.slf4j.Logger; //導入方法依賴的package包/類
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("設置安全策略");
}
}
示例9: fetchSakuraSpeedData
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
}
示例10: fetchAmazonDiscsData
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
}
示例11: info
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* info
* @param logger
* @param message
* @param params
*/
public static void info(Logger logger, String message, Object... params) {
if (logger.isInfoEnabled()) {
logger.info(message, params);
}
}
示例12: getLogLevel
import org.slf4j.Logger; //導入方法依賴的package包/類
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;
}
示例13: info
import org.slf4j.Logger; //導入方法依賴的package包/類
public static void info(Logger logger,String format,Supplier<Object> supplier){
if(logger.isInfoEnabled()){
logger.info(format,supplier.get());
}
}
示例14: enabled
import org.slf4j.Logger; //導入方法依賴的package包/類
@Override
public boolean enabled(Logger logger) {
return logger.isInfoEnabled();
}
示例15: consoleInfo
import org.slf4j.Logger; //導入方法依賴的package包/類
public static void consoleInfo(Logger logger, ScriptObjectMirror args) {
if (logger.isInfoEnabled()) {
logger.info(logMessage(args));
}
}