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

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

Introduction

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

Prototype

void trace(Object message, Throwable t);

Source Link

Document

Logs an error with trace log level.

Usage

From source file:org.hyperic.hq.ui.action.resource.group.control.NewAction.java

/**
 * Create the group control action with the attributes specified in the
 * given <code>GroupControlForm</code>.
 *///from   w w w . j a va 2  s .com
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Log log = LogFactory.getLog(NewAction.class.getName());

    GroupControlForm gForm = (GroupControlForm) form;
    HashMap<String, Object> parms = new HashMap<String, Object>(2);

    try {

        int sessionId = RequestUtils.getSessionId(request).intValue();
        AppdefEntityID appdefId = RequestUtils.getEntityId(request);

        parms.put(Constants.RESOURCE_PARAM, appdefId.getId());
        parms.put(Constants.RESOURCE_TYPE_ID_PARAM, new Integer(appdefId.getType()));

        ActionForward forward = checkSubmit(request, mapping, gForm, parms);
        if (forward != null) {
            return forward;
        }

        ScheduleValue sv = gForm.createSchedule();
        sv.setDescription(gForm.getDescription());

        // make sure that the ControlAction is valid.
        String action = gForm.getControlAction();
        List<String> validActions = controlBoss.getActions(sessionId, appdefId);
        if (!validActions.contains(action)) {
            RequestUtils.setError(request, "resource.common.control.error.ControlActionNotValid", action);
            return returnFailure(request, mapping, parms);
        }

        Integer[] orderSpec = null;
        int[] newOrderSpec = null;
        if (gForm.getInParallel().booleanValue() == GroupControlForm.IN_ORDER.booleanValue()) {
            orderSpec = gForm.getResourceOrdering();
            newOrderSpec = new int[orderSpec.length];
            for (int i = 0; i < orderSpec.length; i++) {
                newOrderSpec[i] = orderSpec[i].intValue();
            }
        }

        if (gForm.getStartTime().equals(GroupControlForm.START_NOW)) {
            controlBoss.doGroupAction(sessionId, appdefId, action, (String) null, newOrderSpec);
        } else {
            controlBoss.doGroupAction(sessionId, appdefId, action, newOrderSpec, sv);
        }

        // set confirmation message
        SessionUtils.setConfirmation(request.getSession(), "resource.common.scheduled.Confirmation");

        return returnSuccess(request, mapping, parms);
    } catch (PluginNotFoundException pnfe) {
        log.trace("no plugin available", pnfe);
        RequestUtils.setError(request, "resource.common.error.PluginNotFound");
        return returnFailure(request, mapping, parms);
    } catch (PluginException cpe) {
        log.trace("control not enabled", cpe);
        RequestUtils.setError(request, "resource.common.error.ControlNotEnabled");
        return returnFailure(request, mapping, parms);
    } catch (PermissionException pe) {
        RequestUtils.setError(request, "resource.group.control.error.NewPermission");
        return returnFailure(request, mapping, parms);
    }
}

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);//from w  w  w.  java2s  . co  m
    else if (level == LogUtil.ERROR)
        log.error(o, t);
    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

public static void performWebStartOfModules(Collection<Module> startedModules, ServletContext servletContext)
        throws ModuleMustStartException, Exception {
    Log log = LogFactory.getLog(Listener.class);

    boolean someModuleNeedsARefresh = false;
    for (Module mod : startedModules) {
        try {/*from  w ww . j  a va  2  s  .  co  m*/
            boolean thisModuleCausesRefresh = WebModuleUtil.startModule(mod, servletContext,
                    /* delayContextRefresh */true);
            someModuleNeedsARefresh = someModuleNeedsARefresh || thisModuleCausesRefresh;
        } catch (Exception e) {
            mod.setStartupErrorMessage("Unable to start module", e);
        }
    }

    if (someModuleNeedsARefresh) {
        try {
            WebModuleUtil.refreshWAC(servletContext, true, null);
        } catch (ModuleMustStartException ex) {
            // pass this up to the calling method so that openmrs loading stops
            throw ex;
        } catch (BeanCreationException ex) {
            // pass this up to the calling method so that openmrs loading stops
            throw ex;
        } catch (Exception e) {
            Throwable rootCause = getActualRootCause(e, true);
            if (rootCause != null) {
                log.fatal("Unable to refresh the spring application context.  Root Cause was:", rootCause);
            } else {
                log.fatal(
                        "Unable to refresh the spring application context. Unloading all modules,  Error was:",
                        e);
            }

            try {
                WebModuleUtil.shutdownModules(servletContext);
                for (Module mod : ModuleFactory.getLoadedModules()) {// use loadedModules to avoid a concurrentmodificationexception
                    if (!mod.isCoreModule() && !mod.isMandatory()) {
                        try {
                            ModuleFactory.stopModule(mod, true, true);
                        } catch (Exception t3) {
                            // just keep going if we get an error shutting down.  was probably caused by the module 
                            // that actually got us to this point!
                            log.trace("Unable to shutdown module:" + mod, t3);
                        }
                    }
                }
                WebModuleUtil.refreshWAC(servletContext, true, null);
            } catch (MandatoryModuleException ex) {
                // pass this up to the calling method so that openmrs loading stops
                throw new MandatoryModuleException(ex.getModuleId(),
                        "Got an error while starting a mandatory module: " + e.getMessage()
                                + ". Check the server logs for more information");
            } catch (Exception t2) {
                // a mandatory or core module is causing spring to fail to start up.  We don't want those
                // stopped so we must report this error to the higher authorities
                log.warn("caught another error: ", t2);
                throw t2;
            }
        }
    }

    // because we delayed the refresh, we need to load+start all servlets and filters now
    // (this is to protect servlets/filters that depend on their module's spring xml config being available)
    for (Module mod : ModuleFactory.getStartedModules()) {
        WebModuleUtil.loadServlets(mod, servletContext);
        WebModuleUtil.loadFilters(mod, servletContext);
    }
}

From source file:org.springframework.aop.interceptor.AbstractTraceInterceptor.java

/**
 * Write the supplied trace message and {@link Throwable} to the
 * supplied {@code Log} instance./*from   w  ww.ja v  a 2 s.c om*/
 * <p>To be called by {@link #invokeUnderTrace} for enter/exit outcomes,
 * potentially including an exception. Note that an exception's stack trace
 * won't get logged when {@link #setLogExceptionStackTrace} is "false".
 * <p>By default messages are written at {@code TRACE} level. Subclasses
 * can override this method to control which level the message is written
 * at, typically also overriding {@link #isLogEnabled} accordingly.
 * @since 4.3.10
 * @see #setLogExceptionStackTrace
 * @see #isLogEnabled
 */
protected void writeToLog(Log logger, String message, @Nullable Throwable ex) {
    if (ex != null && this.logExceptionStackTrace) {
        logger.trace(message, ex);
    } else {
        logger.trace(message);
    }
}

From source file:org.springframework.flex.core.CommonsLoggingTarget.java

public void logEvent(LogEvent logevent) {
    String category = logevent.logger.getCategory();
    if (this.categoryPrefix != null) {
        category = this.categoryPrefix + "." + category;
    }//from w  ww . ja va2s  .c o  m
    Log log = LogFactory.getLog(category);
    switch (logevent.level) {
    case LogEvent.FATAL:
        if (log.isFatalEnabled()) {
            log.fatal(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ERROR:
        if (log.isErrorEnabled()) {
            log.error(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.WARN:
        if (log.isWarnEnabled()) {
            log.warn(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.INFO:
        if (log.isInfoEnabled()) {
            log.info(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.DEBUG:
        if (log.isDebugEnabled()) {
            log.debug(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ALL:
        if (log.isTraceEnabled()) {
            log.trace(logevent.message, logevent.throwable);
        }
        break;
    default:
        break;
    }
}

From source file:org.springframework.orm.toplink.support.CommonsLoggingSessionLog.java

public void log(SessionLogEntry entry) {
    Log logger = LogFactory.getLog(getCategory(entry));
    switch (entry.getLevel()) {
    case SEVERE://from w ww .  j  a v  a 2  s .c  o  m
        if (logger.isErrorEnabled()) {
            if (entry.hasException()) {
                logger.error(getMessageString(entry), getException(entry));
            } else {
                logger.error(getMessageString(entry));
            }
        }
        break;
    case WARNING:
        if (logger.isWarnEnabled()) {
            if (entry.hasException()) {
                logger.warn(getMessageString(entry), getException(entry));
            } else {
                logger.warn(getMessageString(entry));
            }
        }
        break;
    case INFO:
        if (logger.isInfoEnabled()) {
            if (entry.hasException()) {
                logger.info(getMessageString(entry), getException(entry));
            } else {
                logger.info(getMessageString(entry));
            }
        }
        break;
    case CONFIG:
    case FINE:
    case FINER:
        if (logger.isDebugEnabled()) {
            if (entry.hasException()) {
                logger.debug(getMessageString(entry), getException(entry));
            } else {
                logger.debug(getMessageString(entry));
            }
        }
        break;
    case FINEST:
        if (logger.isTraceEnabled()) {
            if (entry.hasException()) {
                logger.trace(getMessageString(entry), getException(entry));
            } else {
                logger.trace(getMessageString(entry));
            }
        }
        break;
    }
}

From source file:org.xflatdb.xflat.query.XPathUpdate.java

private String getStringValue(Object value) {
    if (value == null)
        return null;

    if (value instanceof String)
        return (String) value;

    if (this.conversionService == null || !this.conversionService.canConvert(value.getClass(), String.class)) {
        return null;
    }//from w  w w.  jav  a  2  s . c o  m
    try {
        return this.conversionService.convert(value, String.class);
    } catch (ConversionException ex) {
        Log log = LogFactory.getLog(getClass());
        if (log.isTraceEnabled())
            log.trace("Unable to convert update value to string", ex);
        return null;
    }
}