当前位置: 首页>>代码示例>>Java>>正文


Java Log.warn方法代码示例

本文整理汇总了Java中org.apache.commons.logging.Log.warn方法的典型用法代码示例。如果您正苦于以下问题:Java Log.warn方法的具体用法?Java Log.warn怎么用?Java Log.warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.logging.Log的用法示例。


在下文中一共展示了Log.warn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logException

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@VisibleForTesting
void logException(Log logger, Throwable e, Call call) {
  if (exceptionsHandler.isSuppressedLog(e.getClass())) {
    return; // Log nothing.
  }

  final String logMsg = Thread.currentThread().getName() + ", call " + call;
  if (exceptionsHandler.isTerseLog(e.getClass())) {
    // Don't log the whole stack trace. Way too noisy!
    logger.info(logMsg + ": " + e);
  } else if (e instanceof RuntimeException || e instanceof Error) {
    // These exception types indicate something is probably wrong
    // on the server side, as opposed to just a normal exceptional
    // result.
    logger.warn(logMsg, e);
  } else {
    logger.info(logMsg, e);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:Server.java

示例2: executeInternal

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@Override
protected void executeInternal() throws Throwable
{
    String moduleId = super.getModuleId();
    String name = super.getName();
    Log logger = LogFactory.getLog(moduleId + "." + name);
    switch (logLevel)
    {
    case INFO:
        logger.info(message);
        break;
    case WARN:
        logger.warn(message);
        break;
    case ERROR:
        logger.error(message);
        break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:LoggerModuleComponent.java

示例3: logThreadInfo

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Log the current thread stacks at INFO level.
 * @param log the logger that logs the stack trace
 * @param title a descriptive title for the call stacks
 * @param minInterval the minimum time from the last
 */
public static void logThreadInfo(Log log,
                                 String title,
                                 long minInterval) {
  boolean dumpStack = false;
  if (log.isInfoEnabled()) {
    synchronized (ReflectionUtils.class) {
      long now = System.currentTimeMillis();
      if (now - previousLogTime >= minInterval * 1000) {
        previousLogTime = now;
        dumpStack = true;
      }
    }
    if (dumpStack) {
      try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
        log.info(buffer.toString(Charset.defaultCharset().name()));
      } catch (UnsupportedEncodingException ignored) {
        log.warn("Could not write thread info about '" + title +
            "' due to a string encoding issue.");
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:ReflectionUtils.java

示例4: stopQuietly

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Stop a service; if it is null do nothing. Exceptions are caught and
 * logged at warn level. (but not Throwables). This operation is intended to
 * be used in cleanup operations
 *
 * @param log the log to warn at
 * @param service a service; may be null
 * @return any exception that was caught; null if none was.
 * @see ServiceOperations#stopQuietly(Service)
 */
public static Exception stopQuietly(Log log, Service service) {
  try {
    stop(service);
  } catch (Exception e) {
    log.warn("When stopping the service " + service.getName()
             + " : " + e,
             e);
    return e;
  }
  return null;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:22,代码来源:ServiceOperations.java

示例5: logNodeRefError

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
private static void logNodeRefError(String nodeRefId, Log logger)
{
    if (logger.isWarnEnabled())
    {
        StringBuilder msg = new StringBuilder();
        msg.append("Target Node: ").append(nodeRefId);
        msg.append(" is not a valid NodeRef and has been ignored.");
        logger.warn(msg.toString());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:11,代码来源:NodeRef.java

示例6: addError

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
    final SeverityLevel severityLevel = aEvt.getSeverityLevel();
    if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) {
        final Log log = mLogFactory.getInstance(aEvt.getSourceName());

        final String fileName = aEvt.getFileName();
        final String message = aEvt.getMessage();

        // avoid StringBuffer.expandCapacity
        final int bufLen = message.length() + BUFFER_CUSHION;
        final StringBuffer sb = new StringBuffer(bufLen);

        sb.append("Line: ").append(aEvt.getLine());
        if (aEvt.getColumn() > 0) {
            sb.append(" Column: ").append(aEvt.getColumn());
        }
        sb.append(" Message: ").append(message);

        if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) {
            log.warn(sb.toString());
        }
        else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) {
            log.info(sb.toString());
        }
        else {
            log.error(sb.toString());
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:CommonsLoggingListener.java

示例7: verifyAdminAccess

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Utility method to verify if the current user has access based on the
 * passed {@link AccessControlList}
 * @param authorizer the {@link AccessControlList} to check against
 * @param method the method name to be logged
 * @param module like AdminService or NodeLabelManager
 * @param LOG the logger to use
 * @return {@link UserGroupInformation} of the current user
 * @throws IOException
 */
public static UserGroupInformation verifyAdminAccess(
    YarnAuthorizationProvider authorizer, String method, String module,
    final Log LOG)
    throws IOException {
  UserGroupInformation user;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    LOG.warn("Couldn't get current user", ioe);
    RMAuditLogger.logFailure("UNKNOWN", method, "",
        "AdminService", "Couldn't get current user");
    throw ioe;
  }

  if (!authorizer.isAdmin(user)) {
    LOG.warn("User " + user.getShortUserName() + " doesn't have permission" +
        " to call '" + method + "'");

    RMAuditLogger.logFailure(user.getShortUserName(), method, "", module,
      RMAuditLogger.AuditConstants.UNAUTHORIZED_USER);

    throw new AccessControlException("User " + user.getShortUserName() +
            " doesn't have permission" +
            " to call '" + method + "'");
  }
  if (LOG.isTraceEnabled()) {
    LOG.trace(method + " invoked by user " + user.getShortUserName());
  }
  return user;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:RMServerUtils.java

示例8: setMethodAccessible

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Try to make the method accessible
 * @param method The source arguments
 */
private static void setMethodAccessible(final Method method) {
    try {
        //
        // XXX Default access superclass workaround
        //
        // When a public class has a default access superclass
        // with public methods, these methods are accessible.
        // Calling them from compiled code works fine.
        //
        // Unfortunately, using reflection to invoke these methods
        // seems to (wrongly) to prevent access even when the method
        // modifer is public.
        //
        // The following workaround solves the problem but will only
        // work from sufficiently privilages code.
        //
        // Better workarounds would be greatfully accepted.
        //
        if (!method.isAccessible()) {
            method.setAccessible(true);
        }

    } catch (final SecurityException se) {
        // log but continue just in case the method.invoke works anyway
        final Log log = LogFactory.getLog(MethodUtils.class);
        if (!loggedAccessibleWarning) {
            boolean vulnerableJVM = false;
            try {
                final String specVersion = System.getProperty("java.specification.version");
                if (specVersion.charAt(0) == '1' &&
                        (specVersion.charAt(2) == '0' ||
                         specVersion.charAt(2) == '1' ||
                         specVersion.charAt(2) == '2' ||
                         specVersion.charAt(2) == '3')) {

                    vulnerableJVM = true;
                }
            } catch (final SecurityException e) {
                // don't know - so display warning
                vulnerableJVM = true;
            }
            if (vulnerableJVM) {
                log.warn(
                    "Current Security Manager restricts use of workarounds for reflection bugs "
                    + " in pre-1.4 JVMs.");
            }
            loggedAccessibleWarning = true;
        }
        log.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", se);
    }
}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:56,代码来源:MethodUtils.java

示例9: warn

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Log an I18Nized message to WARN.
 * 
 * @param logger        the logger to use
 * @param messageKey    the message key
 * @param args          the required message arguments
 */
public static final void warn(Log logger, String messageKey, Object ... args)
{
    logger.warn(I18NUtil.getMessage(messageKey, args));
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:12,代码来源:LogUtil.java


注:本文中的org.apache.commons.logging.Log.warn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。