Example usage for com.liferay.portal.kernel.log Log debug

List of usage examples for com.liferay.portal.kernel.log Log debug

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.log Log debug.

Prototype

public void debug(Throwable t);

Source Link

Usage

From source file:au.com.permeance.liferay.portal.kernel.servlet.BaseFilter.java

License:Open Source License

protected void processFilter(Class<?> filterClass, HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws Exception {

    long startTime = 0;

    String threadName = null;//  ww  w.  j a  v  a 2 s  .c o m
    String depther = null;
    String path = null;

    Log log = getLog();

    if (log.isDebugEnabled()) {
        startTime = System.currentTimeMillis();

        Thread currentThread = Thread.currentThread();

        threadName = currentThread.getName();

        depther = (String) request.getAttribute(_DEPTHER);

        if (depther == null) {
            depther = StringPool.BLANK;
        } else {
            depther += StringPool.EQUAL;
        }

        request.setAttribute(_DEPTHER, depther);

        path = request.getRequestURI();

        log.debug("[" + threadName + "]" + depther + "> " + filterClass.getName() + " " + path);
    }

    filterChain.doFilter(request, response);

    if (log.isDebugEnabled()) {
        long endTime = System.currentTimeMillis();

        depther = (String) request.getAttribute(_DEPTHER);

        if (depther == null) {
            return;
        }

        log.debug("[" + threadName + "]" + depther + "< " + filterClass.getName() + " " + path + " "
                + (endTime - startTime) + " ms");

        if (depther.length() > 0) {
            depther = depther.substring(1);
        }

        request.setAttribute(_DEPTHER, depther);
    }
}

From source file:com.liferay.util.log4j.Log4JUtil.java

License:Open Source License

public static void configureLog4J(ClassLoader classLoader) {
    configureLog4J(classLoader.getResource("META-INF/portal-log4j.xml"));
    try {//from w ww. ja v a 2  s . co m
        Log _log = LogFactoryUtil.getLog(Log4JUtil.class);

        String configName = "META-INF/portal-log4j-ext.xml";
        Enumeration<URL> configs = classLoader.getResources(configName);
        if (_log.isDebugEnabled() && !configs.hasMoreElements()) {
            _log.debug("No " + configName + " has been found");
        }
        while (configs.hasMoreElements()) {
            URL config = configs.nextElement();
            configureLog4J(config);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}