本文整理了Java中org.slf4j.Logger.isErrorEnabled()
方法的一些代码示例,展示了Logger.isErrorEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isErrorEnabled()
方法的具体详情如下:
包路径:org.slf4j.Logger
类名称:Logger
方法名:isErrorEnabled
[英]Is the logger instance enabled for the ERROR level?
[中]是否为错误级别启用了记录器实例?
代码示例来源:origin: spring-projects/spring-framework
public void error(Object message) {
if (message instanceof String || this.logger.isErrorEnabled()) {
this.logger.error(String.valueOf(message));
}
}
代码示例来源:origin: com.h2database/h2
@Override
public boolean isEnabled(int level) {
switch (level) {
case TraceSystem.DEBUG:
return logger.isDebugEnabled();
case TraceSystem.INFO:
return logger.isInfoEnabled();
case TraceSystem.ERROR:
return logger.isErrorEnabled();
default:
return false;
}
}
代码示例来源: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: micronaut-projects/micronaut-core
private void logException(Throwable cause) {
//handling connection reset by peer exceptions
if (cause instanceof IOException && IGNORABLE_ERROR_MESSAGE.matcher(cause.getMessage()).matches()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Swallowed an IOException caused by client connectivity: " + cause.getMessage(), cause);
}
} else {
if (LOG.isErrorEnabled()) {
LOG.error("Unexpected error occurred: " + cause.getMessage(), cause);
}
}
}
代码示例来源: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: Netflix/Priam
logger.error("Retry #{} for: {}", retry, e.getMessage());
if (++logCounter == 1 && logger.isInfoEnabled())
logger.info("Exception --> " + ExceptionUtils.getStackTrace(e));
sleeper.sleep(delay);
} else if (delay >= max && retry <= maxRetries) {
if (logger.isErrorEnabled()) {
logger.error(
String.format(
"Retry #%d for: %s",
代码示例来源: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: plutext/docx4j
public AbstractTableWriterModelCell(AbstractTableWriterModel table, int row, int col, Tc tc, Node content) {
super(table, row, col, tc);
this.content = content;
if (content==null) {
if(logger.isErrorEnabled()) {
logger.error("No content for row " + row + ", col " + col + "\n"
+ XmlUtils.marshaltoString(tc, true, true));
}
} else {
if(logger.isDebugEnabled()) {
logger.debug("Cell content for row " + row + ", col " + col + "\n" + XmlUtils.w3CDomNodeToString(content));
}
}
/* xhtmlTc.appendChild(
document.importNode(tcDoc, true) );
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode
org.w3c.dom.DOMException: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation
*/
}
代码示例来源:origin: spring-projects/spring-framework
public void error(Object message, Throwable exception) {
if (message instanceof String || this.logger.isErrorEnabled()) {
this.logger.error(String.valueOf(message), exception);
}
}
代码示例来源: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: micronaut-projects/micronaut-core
if (LOG.isInfoEnabled()) {
LOG.info("De-registered service [{}] with {}", applicationName, discoveryService);
if (LOG.isErrorEnabled()) {
LOG.error("Error occurred de-registering service [" + applicationName + "] with " + discoveryService + ": " + t.getMessage(), t);
代码示例来源: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: micronaut-projects/micronaut-core
@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
Channel channel = ctx.channel();
channel.attr(NettyRxWebSocketSession.WEB_SOCKET_SESSION_KEY).set(null);
if (LOG.isDebugEnabled()) {
LOG.debug("Removing WebSocket Server session: " + session);
}
webSocketSessionRepository.removeChannel(channel);
try {
eventPublisher.publishEvent(new WebSocketSessionClosedEvent(session));
} catch (Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("Error publishing WebSocket closed event: " + e.getMessage(), e);
}
}
super.handlerRemoved(ctx);
}
代码示例来源:origin: micronaut-projects/micronaut-core
@Override
public void onError(Throwable t) {
String errorMessage = getErrorMessage(t, "Error reporting state to Eureka: ");
if (LOG.isErrorEnabled()) {
LOG.error(errorMessage, t);
}
}
代码示例来源: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: micronaut-projects/micronaut-core
GetOperationRequest operationRequest = new GetOperationRequest().withOperationId(operationId);
GetOperationResult result = discoveryClient.getOperation(operationRequest);
if (LOG.isInfoEnabled()) {
LOG.info("Service registration for operation " + operationId + " resulted in " + result.getOperation().getStatus());
if (result.getOperation().getStatus().equalsIgnoreCase("failure")) {
if (route53AutoRegistrationConfiguration.isFailFast() && embeddedServerInstance instanceof EmbeddedServerInstance) {
if (LOG.isErrorEnabled()) {
LOG.error("Error registering instance shutting down instance because failfast is set.");
Thread.currentThread().sleep(5000);
} catch (InterruptedException e) {
if (LOG.isErrorEnabled()) {
LOG.error("Registration monitor service has been aborted, unable to verify proper service registration on Route 53.", e);
代码示例来源:origin: org.slf4j/log4j-over-slf4j
/**
* Determines whether the priority passed as parameter is enabled in the
* underlying SLF4J logger. Each log4j priority is mapped directly to its
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
*
* @param p
* the priority to check against
* @return true if this logger is enabled for the given level, false
* otherwise.
*/
public boolean isEnabledFor(Priority p) {
switch (p.level) {
case Level.TRACE_INT:
return slf4jLogger.isTraceEnabled();
case Level.DEBUG_INT:
return slf4jLogger.isDebugEnabled();
case Level.INFO_INT:
return slf4jLogger.isInfoEnabled();
case Level.WARN_INT:
return slf4jLogger.isWarnEnabled();
case Level.ERROR_INT:
return slf4jLogger.isErrorEnabled();
case Priority.FATAL_INT:
return slf4jLogger.isErrorEnabled();
}
return false;
}
代码示例来源:origin: apache/shiro
if (log.isDebugEnabled()) {
log.debug("Scheduling session validation job using Quartz with " +
"session validation interval of [" + sessionValidationInterval + "]ms...");
if (schedulerImplicitlyCreated) {
scheduler.start();
if (log.isDebugEnabled()) {
log.debug("Successfully started implicitly created Quartz Scheduler instance.");
if (log.isDebugEnabled()) {
log.debug("Session validation job successfully scheduled with Quartz.");
if (log.isErrorEnabled()) {
log.error("Error starting the Quartz session validation job. Session validation may not occur.", e);
代码示例来源:origin: yu199195/hmily
/**
* Error.
*
* @param logger the logger
* @param format the format
* @param supplier the supplier
*/
public static void error(Logger logger, String format, Supplier<Object> supplier) {
if (logger.isErrorEnabled()) {
logger.error(format, supplier.get());
}
}
内容来源于网络,如有侵权,请联系作者删除!