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);

Source Link

Document

Logs a message with error log level.

Usage

From source file:byps.test.TestUtils.java

public static void assertTrue(Log log, String msg, boolean val) {
    if (!val) {
        log.error(msg);
        throw new AssertionError(msg);
    }/*  w  w w .  j ava2 s.c o  m*/
}

From source file:it.doqui.index.ecmengine.client.engine.EcmEngineDelegateFactory.java

private static EcmEngineDelegate getClassInstance(String ecmEngineDelegateImplName, Log logger)
        throws EcmEngineDelegateInstantiationException {
    EcmEngineDelegate classInstance = null;

    logger.debug("[EcmEngineDelegateFactory::getClassInstance] BEGIN");
    try {/*from  w ww.j ava 2  s .  co m*/
        logger.debug("[EcmEngineDelegateFactory::getClassInstance] " + "Caricamento classe: "
                + ecmEngineDelegateImplName);
        final Class delegateClass = Class.forName(ecmEngineDelegateImplName);
        final Constructor constructor = delegateClass.getConstructor(new Class[] { Log.class });

        classInstance = (EcmEngineDelegate) constructor.newInstance(new Object[] { logger });
    } catch (ClassNotFoundException e) {
        logger.error("[EcmEngineDelegateFactory::getClassInstance] " + "FATAL: classe non trovata.");
        throw new EcmEngineDelegateInstantiationException("Classe non trovata.", e);
    } catch (NoSuchMethodException e) {
        logger.error(
                "[EcmEngineDelegateFactory::getClassInstance] " + "FATAL: nessun costruttore compatibile.");
        throw new EcmEngineDelegateInstantiationException("Nessun costruttore compatibile.", e);
    } catch (InstantiationException e) {
        logger.error("[EcmEngineDelegateFactory::getClassInstance] " + "FATAL: errore di istanziazione.");
        throw new EcmEngineDelegateInstantiationException("Errore di istanziazione.", e);
    } catch (IllegalAccessException e) {
        logger.error("[EcmEngineDelegateFactory::getClassInstance] " + "FATAL: errore di accesso.");
        throw new EcmEngineDelegateInstantiationException("Errore di accesso.", e);
    } catch (InvocationTargetException e) {
        logger.error("[EcmEngineDelegateFactory::getClassInstance] " + "FATAL: eccezione nel target invocato.");
        throw new EcmEngineDelegateInstantiationException("Eccezione nel target invocato.", e);
    } finally {
        logger.debug("[EcmEngineDelegateFactory::getClassInstance] END");
    }
    return classInstance;
}

From source file:it.doqui.index.ecmengine.client.backoffice.EcmEngineBackofficeDelegateFactory.java

private static EcmEngineBackofficeDelegate getClassInstance(String ecmEngineBkoDelegateImplName, Log logger)
        throws EcmEngineBackofficeDelegateInstantiationException {
    EcmEngineBackofficeDelegate classInstance = null;

    logger.debug("[EcmEngineBackofficeDelegateFactory::getClassInstance] BEGIN");
    try {//from   www  . jav a2 s  .com
        logger.debug("[EcmEngineBackofficeDelegateFactory::getClassInstance] " + "Caricamento classe: "
                + ecmEngineBkoDelegateImplName);
        final Class delegateClass = Class.forName(ecmEngineBkoDelegateImplName);
        final Constructor constructor = delegateClass.getConstructor(new Class[] { Log.class });
        classInstance = (EcmEngineBackofficeDelegate) constructor.newInstance(new Object[] { logger });
    } catch (ClassNotFoundException e) {
        logger.error("[EcmEngineBackofficeDelegateFactory::getClassInstance] " + "FATAL: classe non trovata.");
        throw new EcmEngineBackofficeDelegateInstantiationException("Classe non trovata.", e);
    } catch (NoSuchMethodException e) {
        logger.error("[EcmEngineBackofficeDelegateFactory::getClassInstance] "
                + "FATAL: nessun costruttore compatibile.");
        throw new EcmEngineBackofficeDelegateInstantiationException("Nessun costruttore compatibile.", e);
    } catch (InstantiationException e) {
        logger.error(
                "[EcmEngineBackofficeDelegateFactory::getClassInstance] " + "FATAL: errore di istanziazione.");
        throw new EcmEngineBackofficeDelegateInstantiationException("Errore di istanziazione.", e);
    } catch (IllegalAccessException e) {
        logger.error("[EcmEngineBackofficeDelegateFactory::getClassInstance] " + "FATAL: errore di accesso.");
        throw new EcmEngineBackofficeDelegateInstantiationException("Errore di accesso.", e);
    } catch (InvocationTargetException e) {
        logger.error("[EcmEngineBackofficeDelegateFactory::getClassInstance] "
                + "FATAL: eccezione nel target invocato.");
        throw new EcmEngineBackofficeDelegateInstantiationException("Eccezione nel target invocato.", e);
    } finally {
        logger.debug("[EcmEngineBackofficeDelegateFactory::getClassInstance] END");
    }
    return classInstance;
}

From source file:com.liveneo.plat.utils.StringUtil.java

/**
 * Encodes a string using algorithm specified in web.xml and return the
 * resulting encrypted password. If exception, the plain credentials string
 * is returned/*from  w ww .  j  ava2 s.  c om*/
 * 
 * @param password
 *            Password or other credentials to use in authenticating this
 *            username
 * @param algorithm
 *            Algorithm used to do the digest
 * @return encypted password based on the algorithm.
 */
public static String encodePassword(String password, String algorithm) {

    if (password == null) {
        return null;
    }

    Log log = LogFactory.getLog(StringUtil.class);
    byte[] unencodedPassword = password.getBytes();

    MessageDigest md = null;

    try {
        // first create an instance, given the provider
        md = MessageDigest.getInstance(algorithm);
    } catch (Exception e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        if (log.isErrorEnabled()) {
            log.error(sw.toString());
        }
        return password;
    }

    md.reset();

    // call the update method one or more times
    // (useful when you don't know the size of your data, e.g. stream)
    md.update(unencodedPassword);

    // now calculate the hash
    byte[] encodedPassword = md.digest();

    StringBuffer buf = new StringBuffer();

    for (int i = 0; i < encodedPassword.length; i++) {
        if ((encodedPassword[i] & 0xff) < 0x10) {
            buf.append("0");
        }

        buf.append(Long.toString(encodedPassword[i] & 0xff, 16));
    }

    return buf.toString();
}

From source file:jp.terasoluna.fw.batch.util.BatchUtil.java

/**
 * ??/* www.j  av  a2s .com*/
 * TLogger / commons.logging ??????
 * @param log 
 * @param logId ?ID
 * @param args ?
 */
private static void logError(Log log, String logId, Object... args) {
    if (log instanceof TLogger) {
        TLogger logger = (TLogger) log;
        logger.error(logId, args);
    } else {
        String msg = LOGGER.getLogMessage(logId, args);
        log.error(msg);
    }
}

From source file:br.octa.exception.LoggedRuntimeException.java

/**
 * Logs the given message and create a RuntimeException object
 *
 * @param msg Error Message/*  w  ww. j  a va 2  s.  c o  m*/
 * @param log Logger who need to consume message
 */
public LoggedRuntimeException(String msg, Log log) {
    super(msg);
    log.error(msg);
}

From source file:io.smartspaces.api.system.internal.osgi.Log4jLoggingProvider.java

@Override
public boolean modifyLogLevel(Log log, String level) {

    log.error("Attempt to modify an unmodifiable logger");

    return false;
}

From source file:com.thoughtworks.go.util.validators.Validation.java

public void logErrors(Log logger) {
    for (Exception error : errors) {
        logger.error(error.getMessage());
    }
}

From source file:com.springsource.insight.plugin.logging.CommonsLoggingOperationCollectionAspectTest.java

@Test
public void testLogErrorMessage() {
    String msg = "testLogErrorMessage";
    Log logger = LogFactory.getLog(getClass());
    logger.error(msg);
    assertLoggingOperation(Log.class, "ERROR", msg, null);
}

From source file:com.telefonica.euro_iaas.paasmanager.rest.aspects.TraceInterceptor.java

protected void writeToLog(Log logger, String message, Throwable ex) {
    if (ex != null) {
        logger.error(ex);
    } else if (message.contains("ENTER")) {
        logger.info(message);//from w  w w  .  j  av  a  2 s .com
    } else if (message.contains("EXIT")) {
        logger.debug(message);
    }
}