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:fr.gouv.vitam.utils.logging.CommonsLoggerTest.java

@Test
public void testWarnWithException() {
    final Log mock = createStrictMock(Log.class);

    mock.warn("a", e);
    replay(mock);//from  w ww  .j a  v  a 2  s .c  o m

    final VitamLogger logger = new CommonsLogger(mock, "foo");
    logger.warn("a", e);
    verify(mock);
}

From source file:net.sourceforge.eclipsetrader.core.internal.LogListener.java

public void logging(IStatus status, String plugin) {
    Log log = LogFactory.getLog(plugin);
    switch (status.getSeverity()) {
    case IStatus.INFO:
        log.info(status.getMessage(), status.getException());
        break;//from   ww w .j  av a 2 s . co  m
    case IStatus.WARNING:
        log.warn(status.getMessage(), status.getException());
        break;
    case IStatus.ERROR:
        log.error(status.getMessage(), status.getException());
        break;
    default:
        log.debug(status.getMessage(), status.getException());
        break;
    }
}

From source file:net.sf.nmedit.nomad.core.service.initService.ExplorerLocationMemory.java

public void init() {
    File file = getTempFile();/*  w  ww. j ava2  s .c  o  m*/
    if (file.exists() && file.isFile()) {
        Properties p = new Properties();
        InputStream in = null;
        try {
            in = new BufferedInputStream(new FileInputStream(file));
            p.load(in);
        } catch (IOException e) {
            Log log = LogFactory.getLog(getClass());
            if (log.isWarnEnabled()) {
                log.warn("could not read property file", e);
            }
            return;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                // no op
            }
        }
        createLocations(p);
    }
}

From source file:net.sf.nmedit.jtheme.store.StorageContext.java

protected Image getImage(URL imageURL) {
    String key = imageURL.toString();
    Image image = imageMap.get(key);
    if (image == null) {
        try {// www .j  ava2s  .c o m
            image = ImageIO.read(imageURL);
            imageMap.put(key, image);
        } catch (IOException e) {
            Log log = getLog();
            if (log.isWarnEnabled()) {
                log.warn("getImage(" + imageURL + ") failed", e);
            }
        }
    }
    return image;
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public void invocationFailed(final Member member, final Object instance, final Exception cause) {
    Log log = getLog(member);
    if (log.isWarnEnabled()) {
        log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.INVOCATION_FAILED, memberToString(member),
                instance, cause.getMessage()), cause);
    }//from w  w  w.jav  a2 s. c  o m
    delegate.invocationFailed(member, instance, cause);
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public void lifecycleInvocationFailed(final MutablePicoContainer container,
        final ComponentAdapter<?> componentAdapter, final Method method, final Object instance,
        final RuntimeException cause) {
    Log log = getLog(method);
    if (log.isWarnEnabled()) {
        log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.LIFECYCLE_INVOCATION_FAILED,
                methodToString(method), instance, cause != null ? cause.getMessage() : "null"), cause);
    }//from ww  w.  j a  va  2s  .  c  o  m
    delegate.lifecycleInvocationFailed(container, componentAdapter, method, instance, cause);
}

From source file:com.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public <T> void instantiationFailed(final PicoContainer container, final ComponentAdapter<T> componentAdapter,
        final Constructor<T> constructor, final Exception cause) {
    Log log = getLog(constructor);
    if (log.isWarnEnabled()) {
        log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATION_FAILED,
                ctorToString(constructor), cause != null ? cause.getMessage() : "null"), cause);
    }//from w  w  w.  j a va 2s. c  o m
    delegate.instantiationFailed(container, componentAdapter, constructor, cause);
}

From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java

/**
 * Logs the message, along with the given <code>throwable</code>, at the warn level. If
 * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
 * with the throwable's <code>Throwable.toString()</code> contents.
 *
 * @param log       where to log the message
 * @param key       the resource key that is associated with the message
 * @param msg       the message to log/*ww w  . ja  v a2s  .c  om*/
 * @param throwable the throwable associated with the message
 */
private static void logWarnWithThrowable(Log log, String key, Msg msg, Throwable throwable) {
    if (Logger.getDumpStackTraces()) {
        log.warn(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg), throwable);
    } else {
        log.warn(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg) + ". Cause: "
                + throwable.toString());
    }
}

From source file:io.smartspaces.workbench.project.test.JunitTestClassDetector.java

/**
 * Does the class have a no argument public constructor?
 *
 * @param clazz//  ww w  .j a v  a 2 s  .  com
 *          the class to test
 * @param log
 *          the logger to use
 *
 * @return {@code true} if the class has a public no arg constructor
 */
private boolean classHasPublicConstructor(Class<?> clazz, Log log) {
    try {
        clazz.getConstructor();

        return true;
    } catch (NoSuchMethodException e) {
        return false;
    } catch (SecurityException e) {
        log.warn(String.format("Potential test class %s caused a security exception. Ignoring.",
                clazz.getName()), e);

        return false;
    }
}

From source file:ductive.log.JDKToCommonsHandler.java

@Override
public void publish(LogRecord record) {
    String name = record.getLoggerName();

    Log log = logs.get(name);
    if (log == null)
        logs.put(name, log = LogFactory.getLog(name));

    String message = record.getMessage();
    Throwable ex = record.getThrown();
    Level level = record.getLevel();

    if (Level.SEVERE == level)
        log.error(message, ex);//from w  w w . j  a  v  a2  s.  c o m
    else if (Level.WARNING == level)
        log.warn(message, ex);
    else if (Level.INFO == level)
        log.info(message, ex);
    else if (Level.CONFIG == level)
        log.debug(message, ex);
    else
        log.trace(message, ex);
}