Example usage for org.apache.commons.logging Log warn

List of usage examples for org.apache.commons.logging Log warn

Introduction

In this page you can find the example usage for org.apache.commons.logging Log warn.

Prototype

void warn(Object message, Throwable t);

Source Link

Document

Logs an error with warn log level.

Usage

From source file:org.springframework.orm.toplink.support.CommonsLoggingSessionLog.java

public void log(SessionLogEntry entry) {
    Log logger = LogFactory.getLog(getCategory(entry));
    switch (entry.getLevel()) {
    case SEVERE:/*from   w w  w  .j  a  va  2  s.c o m*/
        if (logger.isErrorEnabled()) {
            if (entry.hasException()) {
                logger.error(getMessageString(entry), getException(entry));
            } else {
                logger.error(getMessageString(entry));
            }
        }
        break;
    case WARNING:
        if (logger.isWarnEnabled()) {
            if (entry.hasException()) {
                logger.warn(getMessageString(entry), getException(entry));
            } else {
                logger.warn(getMessageString(entry));
            }
        }
        break;
    case INFO:
        if (logger.isInfoEnabled()) {
            if (entry.hasException()) {
                logger.info(getMessageString(entry), getException(entry));
            } else {
                logger.info(getMessageString(entry));
            }
        }
        break;
    case CONFIG:
    case FINE:
    case FINER:
        if (logger.isDebugEnabled()) {
            if (entry.hasException()) {
                logger.debug(getMessageString(entry), getException(entry));
            } else {
                logger.debug(getMessageString(entry));
            }
        }
        break;
    case FINEST:
        if (logger.isTraceEnabled()) {
            if (entry.hasException()) {
                logger.trace(getMessageString(entry), getException(entry));
            } else {
                logger.trace(getMessageString(entry));
            }
        }
        break;
    }
}

From source file:org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService.java

private static Set<TransportHandler> getDefaultTransportHandlers(
        @Nullable Collection<TransportHandler> overrides) {
    Set<TransportHandler> result = new LinkedHashSet<>(8);
    result.add(new XhrPollingTransportHandler());
    result.add(new XhrReceivingTransportHandler());
    result.add(new XhrStreamingTransportHandler());
    result.add(new JsonpPollingTransportHandler());
    result.add(new JsonpReceivingTransportHandler());
    result.add(new EventSourceTransportHandler());
    result.add(new HtmlFileTransportHandler());
    try {//ww w  .ja  v  a 2s  . co  m
        result.add(new WebSocketTransportHandler(new DefaultHandshakeHandler()));
    } catch (Exception ex) {
        Log logger = LogFactory.getLog(DefaultSockJsService.class);
        if (logger.isWarnEnabled()) {
            logger.warn("Failed to create a default WebSocketTransportHandler", ex);
        }
    }
    if (overrides != null) {
        result.addAll(overrides);
    }
    return result;
}

From source file:org.swordess.ldap.util.LogUtils.java

public static void warn(Log log, Object message, Throwable t) {
    if (log.isWarnEnabled()) {
        log.warn(message, t);
    }/*from w w w.  j a  va2 s  . c o m*/
}

From source file:org.xflatdb.xflat.query.XPathUpdate.java

private Content getContentValue(Object value) {
    if (value == null)
        return null;

    if (value instanceof Content)
        return (Content) value;

    if (this.conversionService == null || !this.conversionService.canConvert(value.getClass(), Content.class)) {
        return null;
    }/*from w ww.  jav  a2  s.c o m*/
    try {
        return this.conversionService.convert(value, Content.class);
    } catch (ConversionException ex) {
        Log log = LogFactory.getLog(getClass());
        log.warn("Unable to convert update value to content", ex);
        return null;
    }
}

From source file:uk.ac.sanger.cgp.dbcon.util.InputOutputUtils.java

/**
 * Used instead of IOUtils closeQuietly since they do not log problems
 * to a log instance. This version will do if any exception occurs
 * //from  www .  j  a  va2s.co m
 * @param inputStream
 */
public static void closeQuietly(InputStream inputStream) {
    try {
        if (inputStream != null) {
            inputStream.close();
        }
    } catch (IOException e) {
        Log log = getLog();
        if (log.isWarnEnabled()) {
            log.warn("Could not close the given inputstream", e);
        }
    }
}

From source file:uk.ac.sanger.cgp.dbcon.util.ReaderUtils.java

/**
 * For the given resource this method will return a String which is the local
 * representation of the String input from the resource. Now delagates to
 * the {@link ResourceBuilder} object for the input stream
 * //from   w w  w  .  ja va  2  s . c  o  m
 * @param resource
 *          The resource which must be one of the following forms:
 *          <ul>
 *          <li>file: (for files)</li>
 *          <li>http:// (http)</li>
 *          <li>/ (classpath)</li>
 *          </ul>
 * @return The reader which underneath is a StringReader object. Will be null
 *         if it could not retrieve one
 */
public static Reader returnReaderFromResource(final String resource) {

    InputStream mainStream = null;
    Reader output = null;

    Log log = getLog();

    try {
        Resource resourceObj = ResourceBuilder.getResource(resource);
        mainStream = resourceObj.getInputStream();
        String streamContent = IOUtils.toString(mainStream);
        output = new StringReader(streamContent);
    } catch (DbConException e) {
        if (log.isWarnEnabled()) {
            log.warn("No valid stream could be generated for resource " + resource, e);
        }
    } catch (IOException e) {
        if (log.isWarnEnabled()) {
            log.warn("Error occured whilst converting InputStream to StringReader for resource " + resource, e);
        }
    } finally {
        InputOutputUtils.closeQuietly(mainStream);
    }

    return output;
}

From source file:volker.streaming.music.PropertiesUtil.java

public static void toFile(Log log, Properties properties, String comment, File file, boolean append) {
    if (file == null) {
        log.error("Can't write config to null file.");
    } else {/*from   w  ww .  j a v a2 s  .c  o m*/
        FileWriter writer = null;
        try {
            writer = new FileWriter(file, append);
            if (comment != null) {
                properties.store(writer, comment);
            }
        } catch (IOException e1) {
            log.error("Can't write to config file " + file.getAbsolutePath(), e1);
        }
        try {
            if (writer != null)
                writer.close();
        } catch (IOException e) {
            log.warn("Failed to close config writer", e);
        }
    }
}