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

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

Introduction

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

Prototype

void error(Object message, Throwable t);

Source Link

Document

Logs an error with error log level.

Usage

From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java

/**
 * Signal an RXIo response./*from   www .ja va 2s .c o m*/
 *
 * @param endpoint
 *          the endpoint that received the response
 * @param response
 *          the response
 * @param listeners
 *          the listeners
 * @param log
 *          logger for errors
 */
private void signalRxIoResponse(XBeeCommunicationEndpoint endpoint, RxIoSampleXBeeFrame response,
        List<XBeeResponseListener> listeners, Log log) {
    for (XBeeResponseListener listener : listeners) {
        try {
            listener.onRxIoSampleXBeeResponse(endpoint, response);
        } catch (Exception e) {
            log.error("Error during call to listener for XBee RX IO Sample response", e);
        }
    }
}

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);
    else if (Level.WARNING == level)
        log.warn(message, ex);/*from ww w.j  a  va  2 s  . c  o  m*/
    else if (Level.INFO == level)
        log.info(message, ex);
    else if (Level.CONFIG == level)
        log.debug(message, ex);
    else
        log.trace(message, ex);
}

From source file:com.amazon.carbonado.sequence.SequenceValueProducerPool.java

/**
 * Returns reserved values for all {@link SequenceValueProducer}s.
 *
 * @param log optional log to report errors; uses default log if null
 *//* w  w w .  j  a  v  a2  s.  c o m*/
public void returnReservedValues(Log log) {
    for (SequenceValueProducer producer : values()) {
        try {
            producer.returnReservedValues();
        } catch (RepositoryException e) {
            if (log == null) {
                log = LogFactory.getLog(SequenceValueProducerPool.class);
            }
            log.error(e.getMessage(), e);
        }
    }
}

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

/**
 * Logs the message, along with the given <code>throwable</code>, at the error 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//  w  w  w .jav  a 2s.  c  o  m
 * @param throwable the throwable associated with the message
 */
private static void logErrorWithThrowable(Log log, String key, Msg msg, Throwable throwable) {
    if (Logger.getDumpStackTraces()) {
        log.error(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg), throwable);
    } else {
        log.error(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg) + ". Cause: "
                + throwable.toString());
    }
}

From source file:jatoo.app.AppTexts.java

public AppTexts(Class<?> clazz, Log logger, AppTexts fallback) {

    this.clazz = clazz;
    this.logger = logger;
    this.fallback = fallback;

    try {/*from w  w w.  j  a v a 2s .c  om*/
        resourceBundle = ResourceBundle.getBundle(clazz.getPackage().getName() + ".texts");
    }

    catch (Throwable e) {
        resourceBundle = null;
        logger.error("no texts for class: " + clazz.getName(), e);
    }
}

From source file:com.microsoft.tfs.client.common.ui.wit.form.controls.LabelableControl.java

private void invokeLink(final Shell shell, final WIFormLink link) {
    String url;/*from w  w w.j av a2s .  c o m*/
    try {
        url = link.getURL(getFormContext().getWorkItem());
        Launcher.launch(url);
    } catch (final MacroTargetNotConfiguredException macroEx) {
        MessageDialog.openInformation(shell, macroEx.getMessageTitle(), macroEx.getMessageBody());
    } catch (final Exception ex) {
        final Log log = LogFactory.getLog(LabelableControl.class);
        log.error("Could not launch the browser for link (url)", ex); //$NON-NLS-1$

        final String messageFormat = Messages.getString("LabelableControl.ErrorDialogTextFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, ex.getMessage());
        MessageDialog.openError(shell, Messages.getString("LabelableControl.ErrorDialogTitle"), message); //$NON-NLS-1$
    }
}

From source file:com.netspective.axiom.connection.AbstractConnectionContext.java

public void rollbackAndCloseAndLogAsConnectionLeak(Log log, String message) {
    if (message == null)
        message = "** CONNECTION LEAK DETECTED ** Connection for DataSource '" + getDataSourceId()
                + "' not closed -- rolling back and forcing close now.\n";

    if (log.isErrorEnabled())
        log.error(message, getContextNotClosedException());
    else {//from  w  w  w. j av a2 s  .com
        System.err.println(message);
        getContextNotClosedException().printStackTrace(System.err);
    }
    try {
        rollbackAndClose();
    } catch (SQLException e) {
        log.error("Unable to close leaking connection", e);
    }
}

From source file:com.zxy.commons.profiler.connector.PrintDigestInterceptor.java

protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
    String methodFullName = createInvocationTraceName(invocation);
    try {//  w w  w .ja  va 2s  . com
        Method method = invocation.getMethod();
        if ((!PrintDigestHelper.isMethodNeedSkipPrint(method))
                && (!PrintDigestHelper.isMethodExistsPrintDigest(method))) {
            Object[] args = PrintDigestHelper.getCanPrintArgs(method, invocation.getArguments());

            Profiler.callMark(methodFullName, args, this.defaultPrintLevel);
        }
    } catch (Exception localException) {
        logger.error(localException.getMessage(), localException);
    }
    return invocation.proceed();
}

From source file:com.lolay.citygrid.content.places.detail.DetailIntegration.java

public void testDetail() throws Exception {
    Log log = testDetailLog;
    log.trace("ENTER");

    DetailClient client = new ClientFactory(baseUrl).getDetail();
    DetailInvoker invoker = DetailInvoker.builder().listingId(10100230).clientIp("127.0.0.1").publisher("test")
            .placement("search_page").build();

    DetailResults results = null;/*from  w  w w. j a v  a2  s.  co  m*/
    try {
        long start = System.currentTimeMillis();
        results = invoker.profile(client);
        long end = System.currentTimeMillis();
        log.trace(String.format("Get detail took %s ms", end - start));
    } catch (InvokerException e) {
        log.error(e.getErrorCodes(), e);
        fail();
    }
    assertNotNull(results);
    DetailLocation location = results.getLocation();
    assertNotNull(location);
    DetailAddress address = location.getAddress();
    assertNotNull(address);
    assertNotNull(address.getPostalCode());
    // TODO add validation
}

From source file:com.lolay.citygrid.content.places.search.SearchIntegration.java

public void testWhereCorrection() throws Exception {
    Log log = testWhereCorrectionLog;
    log.trace("ENTER");
    SearchClient searchProxy = new ClientFactory(baseUrl).getSearch();

    SearchInvoker search = SearchInvoker.builder().publisher("acme").what("computr parts").where("90069")
            .placement("junit").build();
    SearchResults results = null;/*from w  ww. jav  a 2s. c o  m*/
    try {
        results = search.where(searchProxy);
    } catch (WebApplicationException e) {
        log.error(e.getResponse(), e);
        fail();
    }
    assertNotNull(results);
    assertNotNull(results.getTotalHits());
    assertEquals((Integer) 0, results.getTotalHits());
    assertNotNull(results.getDidYouMean());
    assertEquals((Integer) 1, results.getFirstHit());
    assertEquals((Integer) 0, results.getLastHit());
    assertNotNull(results.getUri());
    assertNotNull(results.getRegions());
    assertTrue(results.getRegions().size() > 0);
    for (SearchRegion region : results.getRegions()) {
        assertNotNull(region.getType());
        assertNotNull(region.getLatitude());
        assertNotNull(region.getLongitude());
        assertNotNull(region.getDefaultRadius());
    }
}