List of usage examples for org.apache.commons.logging Log isInfoEnabled
boolean isInfoEnabled();
From source file:org.eclipse.smila.utils.workspace.WorkspaceHelper.java
/** * read property $bundleName.workspace to determine and ensure a custom workspace for the given bundle. * /* ww w.j av a 2 s . c o m*/ * @param bundleName * name of bundle * @param log * error log * * @return working dir, if custom bundle workspace has been specified, else null. */ private static File createCustomBundleWorkspace(final String bundleName, final Log log) { File workingDir = null; final String bundleWorkspaceProperty = bundleName + ".workspace"; String customBundleWorkspace = System.getProperty(bundleWorkspaceProperty); if (customBundleWorkspace == null) { customBundleWorkspace = System.getenv(bundleWorkspaceProperty); } if (!StringUtils.isBlank(customBundleWorkspace)) { if (log.isInfoEnabled()) { log.info("Custom workspace for bundle " + bundleName + " is " + customBundleWorkspace); } final File file = new File(customBundleWorkspace); if (!file.exists()) { file.mkdirs(); } if (file.exists() && file.isDirectory()) { workingDir = file; } else { log.error("Creating custom workspace for bundle " + bundleName + " failed, using fallback locations."); } } return workingDir; }
From source file:org.eurekastreams.commons.search.analysis.SynonymMapFactory.java
/** * Initialize the synonym map.// w ww . ja va 2s . co m * * @param thesaurusInputStream * InputStream of the WordNet synonyms file * @return true */ public static boolean inform(final InputStream thesaurusInputStream) { if (synonyms == null) { synchronized (SynonymMapFactory.class) { Log initLog = LogFactory.getLog(SynonymMapFactory.class); initLog.debug("Initializing SynonymMap."); try { // NOTE: the synonym stream is closed inside SynonymMap synonyms = new SynonymMap(thesaurusInputStream); } catch (Exception e) { throw new RuntimeException(e); } initLog.info("Testing SynonymMap."); if (initLog.isInfoEnabled()) { initLog.info("Synonyms for 'success': " + Arrays.toString(synonyms.getSynonyms("success"))); } initLog.info("SynonymMap initializing complete."); } } return true; }
From source file:org.eurekastreams.server.aop.PerformanceTimer.java
/** * Method for logging timing data./* ww w . j av a2s .c om*/ * * @param call * {@link ProceedingJoinPoint} * @return result of wrapped method. * @throws Throwable * on error. */ public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; // get the perf log for target object. Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }
From source file:org.holodeckb2b.ebms3.util.SOAPEnvelopeLogger.java
@Override protected InvocationResponse doProcessing(MessageContext mc) throws Exception { // We use a specific log for the SOAP headers so it can easily be enabled or disabled Log soapEnvLog = LogFactory.getLog("org.holodeckb2b.msgproc.soapenvlog." + (isInFlow(IN_FLOW) || isInFlow(IN_FAULT_FLOW) ? "IN" : "OUT")); // Only do something when logging is enabled if (soapEnvLog.isInfoEnabled()) { soapEnvLog.info(mc.getEnvelope().cloneOMElement().toStringWithConsume() + "\n"); }// w w w . j a va2 s. c o m return InvocationResponse.CONTINUE; }
From source file:org.impalaframework.extension.mvc.util.RequestModelHelper.java
/** * //www . ja v a2s . c om * @param logger * @param request */ public static void maybeDebugRequest(Log logger, HttpServletRequest request) { if (logger.isDebugEnabled()) { logger.debug("#####################################################################################"); logger.debug("---------------------------- Request details ---------------------------------------"); logger.debug("Request context path: " + request.getContextPath()); logger.debug("Request path info: " + request.getPathInfo()); logger.debug("Request path translated: " + request.getPathTranslated()); logger.debug("Request query string: " + request.getQueryString()); logger.debug("Request servlet path: " + request.getServletPath()); logger.debug("Request request URI: " + request.getRequestURI()); logger.debug("Request request URL: " + request.getRequestURL()); logger.debug("Request session ID: " + request.getRequestedSessionId()); logger.debug("------------------------------------------------ "); logger.debug("Parameters ------------------------------------- "); final Enumeration<String> parameterNames = request.getParameterNames(); Map<String, String> parameters = new TreeMap<String, String>(); while (parameterNames.hasMoreElements()) { String name = parameterNames.nextElement(); String value = request.getParameter(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } parameters.put(name, value); } //now output final Set<String> parameterKeys = parameters.keySet(); for (String key : parameterKeys) { logger.debug(key + ": " + parameters.get(key)); } logger.debug("------------------------------------------------ "); Map<String, Object> attributes = new TreeMap<String, Object>(); logger.debug("Attributes ------------------------------------- "); final Enumeration<String> attributeNames = request.getAttributeNames(); while (attributeNames.hasMoreElements()) { String name = attributeNames.nextElement(); Object value = request.getAttribute(name); final String lowerCase = name.toLowerCase(); if (lowerCase.contains("password") || lowerCase.contains("cardnumber")) { value = "HIDDEN"; } attributes.put(name, value); } //now output final Set<String> keys = attributes.keySet(); for (String name : keys) { Object value = attributes.get(name); logger.debug(name + ": " + (value != null ? value.toString() : value)); } logger.debug("------------------------------------------------ "); logger.debug("#####################################################################################"); } else { if (logger.isInfoEnabled()) { logger.info( "#####################################################################################"); logger.info("Request query string: " + request.getQueryString()); logger.info("Request request URI: " + request.getRequestURI()); logger.info( "#####################################################################################"); } } }
From source file:org.infoscoop.command.util.XMLCommandUtil.java
/** * return the CommandResult object that shows execution result of command. * @param uid :userId that executed command * @param commandName :the name of executed command * @param logger :location to output log * @param id :Command id// w w w .j av a 2 s. co m * @param isOK :Whether execution result of command is success or not. * @param message :String that shows the reason when the execution result of command is failure. * @return CommandResult object */ public static CommandResult createResultElement(String uid, String commandName, Log logger, String id, boolean isOK, String message) { String status; if (isOK) { status = "ok"; if (logger.isInfoEnabled()) logger.info("uid:[" + uid + "]: " + commandName + ": OK"); } else { status = "failed"; if (logger.isInfoEnabled()) logger.info("uid:[" + uid + "]: " + commandName + ": Failed:" + message); } CommandResult result = new CommandResult(id, status, message); return result; }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoader.java
/** * Initialize Spring's portlet application context for the given portlet context, * using the application context provided at construction time, or creating a new one * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params. * @param portletContext current portlet context * @return the new PortletApplicationContext * @see #CONTEXT_CLASS_PARAM//from ww w.j a v a 2s . co m * @see #CONFIG_LOCATION_PARAM */ public PortletApplicationContext initWebApplicationContext(PortletContext portletContext) { if (portletContext .getAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize context because there is already a root portlet application context present - " + "check whether you have multiple PortletContextLoader* definitions in your portlet.xml!"); } Log logger = LogFactory.getLog(PortletContextLoader.class); portletContext.log("Initializing Spring root PortletApplicationContext"); if (logger.isInfoEnabled()) { logger.info("Root portlet PortletApplicationContext: initialization started"); } long startTime = System.nanoTime(); try { // Store context in local instance variable, to guarantee that // it is available on PortletContext shutdown. if (this.context == null) { this.context = createPortletApplicationContext(portletContext); } if (this.context instanceof ConfigurablePortletApplicationContext) { configureAndRefreshPortletApplicationContext((ConfigurablePortletApplicationContext) this.context, portletContext); } portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, this.context); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == PortletContextLoader.class.getClassLoader()) { currentContext = this.context; } else if (ccl != null) { currentContextPerThread.put(ccl, this.context); } if (logger.isDebugEnabled()) { logger.debug("Published root PortletApplicationContext as PortletContext attribute with name [" + PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE + "]"); } if (logger.isInfoEnabled()) { long elapsedTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); logger.info("Root PortletApplicationContext: initialization completed in " + elapsedTime + " ms"); } return this.context; } catch (RuntimeException ex) { logger.error("Portlet context initialization failed", ex); portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error err) { logger.error("Portlet context initialization failed", err); portletContext.setAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE, err); throw err; } }
From source file:org.jboss.netty.logging.CommonsLoggerTest.java
@Test public void testIsInfoEnabled() { org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class); expect(mock.isInfoEnabled()).andReturn(true); replay(mock);/* w ww . j a v a 2 s . c om*/ InternalLogger logger = new CommonsLogger(mock, "foo"); assertTrue(logger.isInfoEnabled()); verify(mock); }
From source file:org.kuali.kra.logging.BufferedLogger.java
/** * Wraps {@link Log#info(String)}// ww w. j ava 2s . co m * * @param pattern to format against * @param objs an array of objects used as parameters to the <code>pattern</code> */ public static final void info(Object... objs) { Log log = getLogger(); if (log.isInfoEnabled()) { log.info(getMessage(objs)); } }
From source file:org.latticesoft.util.common.LogUtil.java
public static void main(String args[]) { Log log = LogFactory.getLog(LogUtil.class); System.out.println(LogUtil.isEnabled("WARNING", "WARNING", true)); System.out.println(LogUtil.isEnabled("DEBUG", "WARNING", true)); System.out.println(LogUtil.isEnabled("INFO", "WARNING", true)); System.out.println(LogUtil.isEnabled("ERROR", "WARNING", true)); System.out.println(LogUtil.isEnabled("FATAL", "WARNING", true)); System.out.println("-----"); System.out.println(LogUtil.isEnabled("WARNING", "DEBUG", true)); System.out.println(LogUtil.isEnabled("DEBUG", "DEBUG", true)); System.out.println(LogUtil.isEnabled("INFO", "DEBUG", true)); System.out.println(LogUtil.isEnabled("ERROR", "DEBUG", true)); System.out.println(LogUtil.isEnabled("FATAL", "DEBUG", true)); System.out.println("-----"); System.out.println(LogUtil.isEnabled("WARNING", "INFO", true)); System.out.println(LogUtil.isEnabled("DEBUG", "INFO", true)); System.out.println(LogUtil.isEnabled("INFO", "INFO", true)); System.out.println(LogUtil.isEnabled("ERROR", "INFO", true)); System.out.println(LogUtil.isEnabled("FATAL", "INFO", true)); System.out.println("-----"); System.out.println(LogUtil.isEnabled("WARNING", "ERROR", true)); System.out.println(LogUtil.isEnabled("DEBUG", "ERROR", true)); System.out.println(LogUtil.isEnabled("INFO", "ERROR", true)); System.out.println(LogUtil.isEnabled("ERROR", "ERROR", true)); System.out.println(LogUtil.isEnabled("FATAL", "ERROR", true)); System.out.println("-----"); System.out.println(LogUtil.isEnabled("WARNING", "FATAL", true)); System.out.println(LogUtil.isEnabled("DEBUG", "FATAL", true)); System.out.println(LogUtil.isEnabled("INFO", "FATAL", true)); System.out.println(LogUtil.isEnabled("ERROR", "FATAL", true)); System.out.println(LogUtil.isEnabled("FATAL", "FATAL", true)); System.out.println("-----"); System.out.println(LogUtil.isEnabled("FATAL", "WARNING", false)); if (LogUtil.isEnabled("FATAL", "FATAL", log.isFatalEnabled())) { LogUtil.log(LogUtil.getLevel("FATAL"), "test", null, log); }/*w w w .j a v a2 s. c om*/ if (LogUtil.isEnabled("INFO", LogUtil.INFO, log.isInfoEnabled())) { LogUtil.log(LogUtil.getLevel("INFO"), "test", null, log); } }