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:eu.morfeoproject.fast.catalogue.util.Util.java

/**
 * helper method to retrieve the contents of a resource in the classpath .
 *///from   ww w.  j  ava 2 s .  com
public static String getResource(Log log, String resourceName) {
    InputStream infRulesStream = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(resourceName);
    if (infRulesStream == null) {
        log.error(resourceName + ": resource not found -- check classpath");
        return null;
    }
    StringWriter output = new StringWriter();
    try {
        IOUtils.copy(infRulesStream, output);
        return output.toString();
    } catch (IOException e) {
        log.error(resourceName + ": cannot read resource", e);
        return null;
    } finally {
        IOUtils.closeQuietly(infRulesStream);
    }
}

From source file:edu.indiana.lib.twinpeaks.util.LogUtils.java

/**
 * Serialize an XML object (Document or Element) to the log (with an
 * optional warning header)/*from w ww  .j a  v a2s  .c  o m*/
 * @param log Apache Log object
 * @param errorText Error message (null for none)
 * @param recordElement The XML object to disolay (Document, Element)
 */
public static void displayXml(org.apache.commons.logging.Log log, String errorText, Object xmlObject) {

    if (!(xmlObject instanceof Document) && !(xmlObject instanceof Element)) {
        throw new IllegalArgumentException("Unexpected object for serialzation: " + xmlObject.toString());
    }

    if (!StringUtils.isNull(errorText)) {
        log.error(errorText);
    }

    log.info("Record Start ----------------------------------------");

    try {
        log.info(DomUtils.serialize(xmlObject));
    } catch (DomException exception) {
        log.error("Failed to serialize element " + xmlObject.toString(), exception);
    }
    log.info("Record End ------------------------------------------");
}

From source file:modula.parser.io.ModelUpdater.java

/**
 * /*www  . j av  a  2  s .c o  m*/
 */
private static void logAndThrowModelError(final String errType, final Object[] msgArgs) throws ModelException {
    MessageFormat msgFormat = new MessageFormat(errType);
    String errMsg = msgFormat.format(msgArgs);
    org.apache.commons.logging.Log log = LogFactory.getLog(ModelUpdater.class);
    log.error(errMsg);
    throw new ModelException(errMsg);
}

From source file:eu.planets_project.tb.impl.persistency.CommentPersistencyImpl.java

/**
 * A Factory method to build a reference to this interface.
 * @return/*from w  ww.  j av  a  2  s .co m*/
 */
public static CommentPersistencyRemote getInstance() {
    Log log = LogFactory.getLog(CommentPersistencyImpl.class);
    try {
        Context jndiContext = new javax.naming.InitialContext();
        CommentPersistencyRemote dao_r = (CommentPersistencyRemote) PortableRemoteObject.narrow(
                jndiContext.lookup("testbed/CommentPersistencyImpl/remote"), CommentPersistencyRemote.class);
        return dao_r;
    } catch (NamingException e) {
        log.error("Failure in getting PortableRemoteObject: " + e.toString());
        return null;
    }
}

From source file:net.openhft.chronicle.logger.jcl.JclTestBase.java

protected static void log(Log logger, ChronicleLogLevel level, String message) {
    switch (level) {
    case TRACE:/*from  w  ww  . j  a v a2  s .c o  m*/
        logger.trace(message);
        break;
    case DEBUG:
        logger.debug(message);
        break;
    case INFO:
        logger.info(message);
        break;
    case WARN:
        logger.warn(message);
        break;
    case ERROR:
        logger.error(message);
        break;
    default:
        throw new UnsupportedOperationException();
    }
}

From source file:eu.planets_project.tb.impl.persistency.ServiceRecordPersistencyImpl.java

/**
 * A Factory method to build a reference to this interface.
 * @return/*  w w w  .  ja  va 2  s. c  o  m*/
 */
public static ServiceRecordPersistencyRemote getInstance() {
    Log log = LogFactory.getLog(ServiceRecordPersistencyImpl.class);
    try {
        Context jndiContext = new javax.naming.InitialContext();
        ServiceRecordPersistencyRemote dao_r = (ServiceRecordPersistencyRemote) PortableRemoteObject.narrow(
                jndiContext.lookup("testbed/ServiceRecordPersistencyImpl/remote"),
                ServiceRecordPersistencyRemote.class);
        return dao_r;
    } catch (NamingException e) {
        log.error("Failure in getting PortableRemoteObject: " + e.toString());
        return null;
    }
}

From source file:com.runwaysdk.logging.RunwayLogUtil.java

public static void logToLevel(Log log, LogLevel level, String msg) {
    if (level == LogLevel.TRACE) {
        log.trace(msg);//from  ww w  .j av  a2  s  . co m
    } else if (level == LogLevel.DEBUG) {
        log.debug(msg);
    } else if (level == LogLevel.INFO) {
        log.info(msg);
    } else if (level == LogLevel.WARN) {
        log.warn(msg);
    } else if (level == LogLevel.ERROR) {
        log.error(msg);
    } else if (level == LogLevel.FATAL) {
        log.fatal(msg);
    } else {
        log.fatal(
                "RunwayLogUtil.logToLevel was called, but an invalid level was specified. Here is the message we were passed: '"
                        + msg + "'");
    }
}

From source file:eu.planets_project.tb.impl.persistency.TestbedServiceTemplatePersistencyImpl.java

/**
 * A Factory method to build a reference to this interface.
 * @return/*from   ww  w.j  ava  2  s  .  c  om*/
 */
public static TestbedServiceTemplatePersistencyRemote getInstance() {
    Log log = LogFactory.getLog(TestbedServiceTemplatePersistencyImpl.class);
    try {
        Context jndiContext = new javax.naming.InitialContext();
        TestbedServiceTemplatePersistencyRemote dao_r = (TestbedServiceTemplatePersistencyRemote) PortableRemoteObject
                .narrow(jndiContext.lookup("testbed/TestbedServiceTemplatePersistencyImpl/remote"),
                        TestbedServiceTemplatePersistencyRemote.class);
        return dao_r;
    } catch (NamingException e) {
        log.error("Failure in getting PortableRemoteObject: " + e.toString());
        return null;
    }
}

From source file:corina.logging.CorinaLog.java

private static PrintStream createPrintStream(final Log log, final boolean error) {
    return new PrintStream(new OutputStream() {
        public void write(int b) {
            byte[] barray = { (byte) b };
            write(barray, 0, 1);/*  w  ww  .j  ava2s .  c  om*/
        }

        public void write(byte[] b, int off, int len) {
            String str = new String(b, off, len);
            // skip any trailing EOL
            if ("\r".equals(str) || "\n".equals(str) || "\r\n".equals(str))
                return;
            if (error) {
                log.error(str);
            } else {
                log.info(str);
            }
        }
    });
}

From source file:byps.test.TestUtils.java

public static void fail(Log log, String msg) {
    log.error(msg);
    throw new AssertionError(msg);
}