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

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

Introduction

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

Prototype

void debug(Object message, Throwable t);

Source Link

Document

Logs an error with debug log level.

Usage

From source file:org.jasig.portal.jmx.JavaManagementServerListener.java

/**
 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
 *///ww  w .j  ava2  s  .c  o m
public void contextInitialized(ServletContextEvent event) {
    Log logger = LogFactory.getLog(LOGGER_NAME);
    final ServletContext servletContext = event.getServletContext();

    //Create the bean
    this.javaManagementServerBean = new JavaManagementServerBean();

    //Get the failOnException option
    final String failOnExceptionStr = servletContext.getInitParameter(FAIL_ON_EXCEPTION);
    boolean failOnException = Boolean.parseBoolean(failOnExceptionStr);
    this.javaManagementServerBean.setFailOnException(failOnException);

    final String host = servletContext.getInitParameter(JMX_RMI_HOST);
    this.javaManagementServerBean.setHost(host);

    //Get the base rmi port from the init parameters
    final String portOneStr = servletContext.getInitParameter(JMX_RMI_PORT_1);
    try {
        final int portOne = Integer.parseInt(portOneStr);
        this.javaManagementServerBean.setPortOne(portOne);
    } catch (NumberFormatException nfe) {
        logger.warn("init-parameter '" + JMX_RMI_PORT_1 + "' is required and must contain a number. '"
                + portOneStr + "' is not a valid number.", nfe);
    }

    //Get the second rmi port from the init parameters
    final String portTwoStr = servletContext.getInitParameter(JMX_RMI_PORT_2);
    try {
        final int portTwo = Integer.parseInt(portTwoStr);
        this.javaManagementServerBean.setPortTwo(portTwo);
    } catch (NumberFormatException nfe) {
        logger.debug("Failed to convert init-parameter '" + JMX_RMI_PORT_2 + "' with value '" + portTwoStr
                + "' to a number, defaulting portTwo to portOne + 1", nfe);
    }

    this.javaManagementServerBean.startServer();
}

From source file:org.jboss.netty.logging.CommonsLoggerTest.java

@Test
public void testDebugWithException() {
    org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class);

    mock.debug("a", e);
    replay(mock);/* w w w  .  ja va 2  s. c o  m*/

    InternalLogger logger = new CommonsLogger(mock, "foo");
    logger.debug("a", e);
    verify(mock);
}

From source file:org.latticesoft.util.common.LogUtil.java

public static void log(int level, Object o, Throwable t, Log log) {
    if (level == LogUtil.DEBUG)
        log.debug(o, t);
    else if (level == LogUtil.ERROR)
        log.error(o, t);/*from  w ww  .j  av  a  2s. com*/
    else if (level == LogUtil.FATAL)
        log.fatal(o, t);
    else if (level == LogUtil.INFO)
        log.info(o, t);
    else if (level == LogUtil.TRACE)
        log.trace(o, t);
    else if (level == LogUtil.WARNING)
        log.warn(o, t);
}

From source file:org.openmrs.web.Listener.java

/**
 * Convenience method to empty out the dwr-modules.xml file to fix any errors that might have
 * occurred in it when loading or unloading modules.
 *
 * @param servletContext//from   ww w  .j  a  v  a2  s.  co  m
 */
private void clearDWRFile(ServletContext servletContext) {
    Log log = LogFactory.getLog(Listener.class);

    String realPath = servletContext.getRealPath("");
    String absPath = realPath + "/WEB-INF/dwr-modules.xml";
    File dwrFile = new File(absPath.replace("/", File.separator));
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setEntityResolver(new EntityResolver() {

            public InputSource resolveEntity(String publicId, String systemId)
                    throws SAXException, IOException {
                // When asked to resolve external entities (such as a DTD) we return an InputSource
                // with no data at the end, causing the parser to ignore the DTD.
                return new InputSource(new StringReader(""));
            }
        });
        Document doc = db.parse(dwrFile);
        Element elem = doc.getDocumentElement();
        elem.setTextContent("");
        OpenmrsUtil.saveDocument(doc, dwrFile);
    } catch (Exception e) {
        // got here because the dwr-modules.xml file is empty for some reason.  This might
        // happen because the servlet container (i.e. tomcat) crashes when first loading this file
        log.debug("Error clearing dwr-modules.xml", e);
        dwrFile.delete();
        FileWriter writer = null;
        try {
            writer = new FileWriter(dwrFile);
            writer.write(
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE dwr PUBLIC \"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN\" \"http://directwebremoting.org/schema/dwr20.dtd\">\n<dwr></dwr>");
        } catch (IOException io) {
            log.error("Unable to clear out the " + dwrFile.getAbsolutePath()
                    + " file.  Please redeploy the openmrs war file", io);
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException io) {
                    log.warn("Couldn't close Writer: " + io);
                }
            }
        }
    }
}

From source file:org.ops4j.gaderian.service.impl.LoggingUtils.java

public static void exception(Log log, String methodName, Throwable t) {
    StringBuffer buffer = new StringBuffer(BUFFER_SIZE);

    buffer.append("EXCEPTION ");
    buffer.append(methodName);//  ww w .  j  a v a  2 s. com
    buffer.append("() -- ");

    buffer.append(t.getClass().getName());

    log.debug(buffer.toString(), t);
}

From source file:org.pentaho.database.dialect.AbstractDatabaseDialect.java

@Override
public Driver getDriver(String url) {
    try {/*from w w  w.  ja  v a 2  s.c o m*/
        return DriverManager.getDriver(url);
    } catch (SQLException e) {
        Log logger = LogFactory.getLog(IDatabaseDialect.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to get driver for url " + url, e);
        }
    }
    return null;
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Trace throwable./*ww w  . ja va  2  s . co  m*/
 *
 * @param   tracingClass    Class that wants to make a trace entry.
 * @param   tracingObject   Instance that wants to make a trace entry.
 * @param   method          Method of that object.
 * @param   throwable       Throwable to trace.
 */
public static void trace(final Class tracingClass, final Object tracingObject, final String method,
        final Throwable throwable) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isDebugEnabled()) {
            log.debug("." + method + " " + throwable, throwable);
        }
    }
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Trace throwable./*from ww w  .  j  a va2 s . c o m*/
 *
 * @param   tracingClass    Class that wants to make a trace entry.
 * @param   method          Method of that class.
 * @param   throwable       Throwable to trace.
 */
public static void trace(final Class tracingClass, final String method, final Throwable throwable) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isDebugEnabled()) {
            log.debug("." + method + " " + throwable, throwable);
        }
    }
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Trace throwable and extra description.
 *
 * @param   tracingClass    Class that wants to make a trace entry.
 * @param   tracingObject   Instance that wants to make a trace entry.
 * @param   method          Method of that object.
 * @param   description     Further information.
 * @param   throwable       Throwable to trace.
 *//*from   w ww  .j  a va2  s.  c  o m*/
public static void trace(final Class tracingClass, final Object tracingObject, final String method,
        final String description, final Throwable throwable) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isDebugEnabled()) {
            log.debug("." + method + " " + description, throwable);
        }
    }
}

From source file:org.qedeq.base.trace.Trace.java

/**
 * Trace throwable and extra description.
 *
 * @param   tracingClass    Class that wants to make a trace entry.
 * @param   method          Method of that class.
 * @param   description     Further information.
 * @param   throwable       Throwable to trace.
 *//* w ww  . j  a  va2s.  co m*/
public static void trace(final Class tracingClass, final String method, final String description,
        final Throwable throwable) {
    if (traceOn) {
        final Log log = LogFactory.getFactory().getInstance(tracingClass);
        if (log.isDebugEnabled()) {
            log.debug("." + method + " " + description, throwable);
        }
    }
}