本文整理了Java中org.slf4j.Logger.isWarnEnabled()
方法的一些代码示例,展示了Logger.isWarnEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isWarnEnabled()
方法的具体详情如下:
包路径:org.slf4j.Logger
类名称:Logger
方法名:isWarnEnabled
[英]Is the logger instance enabled for the WARN level?
[中]记录器实例是否已启用警告级别?
代码示例来源:origin: spring-projects/spring-framework
public void warn(Object message) {
if (message instanceof String || this.logger.isWarnEnabled()) {
this.logger.warn(String.valueOf(message));
}
}
代码示例来源:origin: wildfly/wildfly
private boolean infoOrHigherEnabled(final Level level) {
if (level == Level.INFO) {
return logger.isInfoEnabled();
} else if (level == Level.WARN) {
return logger.isWarnEnabled();
} else if (level == Level.ERROR || level == Level.FATAL) {
return logger.isErrorEnabled();
}
return true;
}
代码示例来源:origin: oblac/jodd
@Override
public boolean isEnabled(final Level level) {
switch (level) {
case TRACE: return logger.isTraceEnabled();
case DEBUG: return logger.isDebugEnabled();
case INFO: return logger.isInfoEnabled();
case WARN: return logger.isWarnEnabled();
case ERROR: return logger.isErrorEnabled();
default:
throw new IllegalArgumentException();
}
}
代码示例来源:origin: plutext/docx4j
result = xPath.evaluate(xpathString, doc );
if (result.equals("") && log.isWarnEnabled()) {
log.warn("No match for " + xpathString + " so result is empty string");
} else {
log.debug(xpathString + " ---> '" + result + "'");
log.debug(xpathString + " ---> '" + result + "'");
代码示例来源:origin: apache/flink
@Override
public void close() throws IOException {
if (this.invalidLineCount > 0) {
if (LOG.isWarnEnabled()) {
LOG.warn("In file \"" + currentSplit.getPath() + "\" (split start: " + this.splitStart + ") " + this.invalidLineCount +" invalid line(s) were skipped.");
}
}
if (this.commentCount > 0) {
if (LOG.isInfoEnabled()) {
LOG.info("In file \"" + currentSplit.getPath() + "\" (split start: " + this.splitStart + ") " + this.commentCount +" comment line(s) were skipped.");
}
}
super.close();
}
代码示例来源:origin: apache/flink
@Override
public BaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
// only gather base statistics for FileInputFormats
if (!(mapredInputFormat instanceof FileInputFormat)) {
return null;
}
final FileBaseStatistics cachedFileStats = (cachedStats instanceof FileBaseStatistics) ?
(FileBaseStatistics) cachedStats : null;
try {
final org.apache.hadoop.fs.Path[] paths = FileInputFormat.getInputPaths(this.jobConf);
return getFileStats(cachedFileStats, paths, new ArrayList<FileStatus>(1));
} catch (IOException ioex) {
if (LOG.isWarnEnabled()) {
LOG.warn("Could not determine statistics due to an io error: "
+ ioex.getMessage());
}
} catch (Throwable t) {
if (LOG.isErrorEnabled()) {
LOG.error("Unexpected problem while getting the file statistics: "
+ t.getMessage(), t);
}
}
// no statistics available
return null;
}
代码示例来源:origin: apache/hive
LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
" ignored for rewriting as its contents are outdated");
continue;
if (LOG.isDebugEnabled()) {
LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
" was not in the cache");
if (LOG.isWarnEnabled()) {
LOG.info("Materialized view " + materializedViewTable.getFullyQualifiedName() + " was skipped "
+ "because cache has not been loaded yet");
代码示例来源:origin: org.slf4j/log4j-over-slf4j
/**
* Return the level in effect for this category/logger.
*
* <p>
* The result is computed by simulation.
*
* @return
*/
public Level getEffectiveLevel() {
if (slf4jLogger.isTraceEnabled()) {
return Level.TRACE;
}
if (slf4jLogger.isDebugEnabled()) {
return Level.DEBUG;
}
if (slf4jLogger.isInfoEnabled()) {
return Level.INFO;
}
if (slf4jLogger.isWarnEnabled()) {
return Level.WARN;
}
return Level.ERROR;
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
@Override
public boolean isEnabled(int level) {
switch (level) {
case com.jcraft.jsch.Logger.DEBUG:
return LOG.isDebugEnabled();
case com.jcraft.jsch.Logger.INFO:
return LOG.isInfoEnabled();
case com.jcraft.jsch.Logger.WARN:
return LOG.isWarnEnabled();
case com.jcraft.jsch.Logger.ERROR:
case com.jcraft.jsch.Logger.FATAL:
return LOG.isErrorEnabled();
default:
return false;
}
}
代码示例来源:origin: spring-projects/spring-framework
public void warn(Object message, Throwable exception) {
if (message instanceof String || this.logger.isWarnEnabled()) {
this.logger.warn(String.valueOf(message), exception);
}
}
代码示例来源:origin: apache/shiro
"error? (Typical or expected login exceptions should extend from AuthenticationException).";
ae = new AuthenticationException(msg, t);
if (log.isWarnEnabled())
log.warn(msg, t);
if (log.isWarnEnabled()) {
String msg = "Unable to send notification for failed authentication attempt - listener error?. " +
"Please check your AuthenticationListener implementation(s). Logging sending exception " +
"and propagating original AuthenticationException instead...";
log.warn(msg, t2);
log.debug("Authentication successful for token [{}]. Returned account [{}]", token, info);
代码示例来源:origin: networknt/light-4j
private void reconnectService() {
Collection<URL> allRegisteredServices = getRegisteredServiceUrls();
if (allRegisteredServices != null && !allRegisteredServices.isEmpty()) {
try {
serverLock.lock();
for (URL url : getRegisteredServiceUrls()) {
doRegister(url);
}
if(logger.isInfoEnabled()) logger.info("[{}] reconnect: register services {}", registryClassName, allRegisteredServices);
for (URL url : availableServices) {
if (!getRegisteredServiceUrls().contains(url)) {
if(logger.isWarnEnabled()) logger.warn("reconnect url not register. url:{}", url);
continue;
}
doAvailable(url);
}
if(logger.isInfoEnabled()) logger.info("[{}] reconnect: available services {}", registryClassName, availableServices);
} finally {
serverLock.unlock();
}
}
}
}
代码示例来源:origin: apache/flink
@Override
public BaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
// only gather base statistics for FileInputFormats
if (!(mapreduceInputFormat instanceof FileInputFormat)) {
return null;
}
JobContext jobContext = new JobContextImpl(configuration, null);
final FileBaseStatistics cachedFileStats = (cachedStats instanceof FileBaseStatistics) ?
(FileBaseStatistics) cachedStats : null;
try {
final org.apache.hadoop.fs.Path[] paths = FileInputFormat.getInputPaths(jobContext);
return getFileStats(cachedFileStats, paths, new ArrayList<FileStatus>(1));
} catch (IOException ioex) {
if (LOG.isWarnEnabled()) {
LOG.warn("Could not determine statistics due to an io error: "
+ ioex.getMessage());
}
} catch (Throwable t) {
if (LOG.isErrorEnabled()) {
LOG.error("Unexpected problem while getting the file statistics: "
+ t.getMessage(), t);
}
}
// no statistics available
return null;
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public boolean isEnabled(int level) {
switch (level) {
case DEBUG:
return log.isDebugEnabled();
case INFO:
return log.isInfoEnabled();
case WARN:
return log.isWarnEnabled();
case ERROR:
return log.isErrorEnabled();
case FATAL:
return log.isErrorEnabled();
default:
return false;
}
}
代码示例来源:origin: apache/storm
private static void joinThread(Thread t) {
while (t.isAlive()) {
try {
t.join();
} catch (InterruptedException ie) {
if (LOG.isWarnEnabled()) {
LOG.warn("Interrupted while joining on: " + t, ie);
}
t.interrupt(); // propagate interrupt
}
}
}
代码示例来源:origin: plutext/docx4j
= (CustomXmlDataStoragePart)customXmlParts.get(itemId);
if (customXmlDataStoragePart==null) {
log.warn("Couldn't find CustomXmlDataStoragePart referenced from sdt bound with " + itemId);
} else {
log.debug("Using " + itemId);
if(log.isWarnEnabled()) {
log.warn("Couldn't find CustomXmlDataStoragePart referenced from " + XmlUtils.marshaltoString(element));
log.debug("Using " + element.getSdtPr().getDataBinding().getStoreItemID());
customXmlDataStoragePart = (CustomXmlDataStoragePart)customXmlParts.get(itemId);
log.warn("TODO: support StandardisedAnswersPart");
return;
代码示例来源:origin: apache/flink
if (Optimizer.LOG.isWarnEnabled()) {
Optimizer.LOG.warn("Could not instantiate InputFormat to obtain statistics."
+ " Limited statistics will be available.", t);
if (Optimizer.LOG.isWarnEnabled()) {
Optimizer.LOG.warn("Error obtaining statistics from input format: " + t.getMessage(), t);
final long len = bs.getTotalInputSize();
if (len == BaseStatistics.SIZE_UNKNOWN) {
if (Optimizer.LOG.isInfoEnabled()) {
Optimizer.LOG.info("Compiler could not determine the size of input '" + inFormatDescription + "'. Using default estimates.");
代码示例来源:origin: apache/flink
/**
* Obtains basic file statistics containing only file size. If the input is a directory, then the size is the sum of all contained files.
*
* @see org.apache.flink.api.common.io.InputFormat#getStatistics(org.apache.flink.api.common.io.statistics.BaseStatistics)
*/
@Override
public FileBaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
final FileBaseStatistics cachedFileStats = cachedStats instanceof FileBaseStatistics ?
(FileBaseStatistics) cachedStats : null;
try {
return getFileStats(cachedFileStats, getFilePaths(), new ArrayList<>(getFilePaths().length));
} catch (IOException ioex) {
if (LOG.isWarnEnabled()) {
LOG.warn("Could not determine statistics for paths '" + Arrays.toString(getFilePaths()) + "' due to an io error: "
+ ioex.getMessage());
}
}
catch (Throwable t) {
if (LOG.isErrorEnabled()) {
LOG.error("Unexpected problem while getting the file statistics for paths '" + Arrays.toString(getFilePaths()) + "': "
+ t.getMessage(), t);
}
}
// no statistics available
return null;
}
代码示例来源:origin: kiegroup/optaplanner
private String resolveLoggingLevel(String loggerName) {
Logger logger = LoggerFactory.getLogger(loggerName);
if (logger.isTraceEnabled()) {
return "trace";
} else if (logger.isDebugEnabled()) {
return "debug";
} else if (logger.isInfoEnabled()) {
return "info";
} else if (logger.isWarnEnabled()) {
return "warn";
} else if (logger.isErrorEnabled()) {
return "error";
} else {
throw new IllegalStateException("Logging level for loggerName (" + loggerName + ") cannot be determined.");
}
}
代码示例来源:origin: yu199195/hmily
/**
* Warn.
*
* @param logger the logger
* @param format the format
* @param supplier the supplier
*/
public static void warn(Logger logger, String format, Supplier<Object> supplier) {
if (logger.isWarnEnabled()) {
logger.warn(format, supplier.get());
}
}
内容来源于网络,如有侵权,请联系作者删除!