List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:org.openadaptor.util.JDBCUtil.java
public static void logCurrentResultSetRow(Log log, String msg, ResultSet rs) throws SQLException { if (log.isDebugEnabled()) { ResultSetMetaData rsmd = rs.getMetaData(); if (msg != null) { log.debug(msg); }//from www. j av a 2 s. c o m for (int i = 1; i <= rsmd.getColumnCount(); i++) { log.debug(" " + rsmd.getColumnName(i) + " (" + rsmd.getColumnClassName(i) + ") = " + rs.getString(i)); } } }
From source file:org.opencms.pdftools.CmsXRLogAdapter.java
/** * Sends a log message to the commons-logging interface.<p> * * @param level the log level/*from w ww .ja v a2 s . c o m*/ * @param message the message * @param log the commons logging log object * @param e a throwable or null */ private void sendMessageToLogger(Level level, String message, Log log, Throwable e) { if (e == null) { if (level == Level.SEVERE) { log.error(message); } else if (level == Level.WARNING) { log.warn(message); } else if (level == Level.INFO) { log.info(message); } else if (level == Level.CONFIG) { log.info(message); } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) { log.debug(message); } else { log.info(message); } } else { if (level == Level.SEVERE) { log.error(message, e); } else if (level == Level.WARNING) { log.warn(message, e); } else if (level == Level.INFO) { log.info(message, e); } else if (level == Level.CONFIG) { log.info(message, e); } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) { log.debug(message, e); } else { log.info(message, e); } } }
From source file:org.opendatakit.common.persistence.engine.gae.QueryImpl.java
final static synchronized void updateCostLoggingThreshold(DatastoreImpl datastore) { Log logger = LogFactory.getLog(QueryImpl.class); long currentTime = System.currentTimeMillis(); if (milliLastCheck + ACTIVE_COST_LOGGING_CHECK_INTERVAL < currentTime) { milliLastCheck = currentTime;// update early in case an exception is // thrown... try {/*from w w w. j a v a 2 s .co m*/ com.google.appengine.api.datastore.Query query = new Query("_COST_LOGGING_"); PreparedQuery pq = datastore.getDatastoreService().prepare(query); logger.debug("costLogging fetch."); List<com.google.appengine.api.datastore.Entity> eList = pq .asList(FetchOptions.Builder.withDefaults()); datastore.recordQueryUsage("_COST_LOGGING_", eList.size()); if (eList.isEmpty()) { costLoggingMinimumMegacyclesThreshold = 10 * 1200; // 10 seconds... logger.warn("writing 10-second cost logging threshold record"); com.google.appengine.api.datastore.Entity e = new com.google.appengine.api.datastore.Entity( "_COST_LOGGING_", "T" + WebUtils.iso8601Date(new Date())); e.setProperty("COST_LOGGING_MEGACYCLE_THRESHOLD", 10 * 1200); // 10 // seconds... e.setProperty("LAST_UPDATE_DATE", new Date()); datastore.getDatastoreService().put(e); } else { Long newValue = null; for (com.google.appengine.api.datastore.Entity e : eList) { Object o = e.getProperty("COST_LOGGING_MEGACYCLE_THRESHOLD"); if (o != null) { if (o instanceof Long) { Long l = (Long) o; if (newValue == null || newValue.compareTo(l) > 0) { newValue = l; } else { logger.warn("deleting superceded logging threshold record"); datastore.getDatastoreService().delete(e.getKey()); } } else if (o instanceof Integer) { Integer i = (Integer) o; Long l = Long.valueOf(i); if (newValue == null || newValue.compareTo(l) > 0) { newValue = l; } else { logger.warn("deleting superceded logging threshold record"); datastore.getDatastoreService().delete(e.getKey()); } } else if (o instanceof String) { String s = (String) o; try { Long l = Long.parseLong(s); if (newValue == null || newValue.compareTo(l) > 0) { newValue = l; } else { logger.warn("deleting superceded logging threshold record"); datastore.getDatastoreService().delete(e.getKey()); } } catch (NumberFormatException ex) { logger.warn("deleting superceded logging threshold record"); datastore.getDatastoreService().delete(e.getKey()); } } else { logger.warn("deleting superceded logging threshold record"); datastore.getDatastoreService().delete(e.getKey()); } } } if (newValue == null) { logger.warn("resetting cost logging to 10 second (12000 megacycle) threshold"); costLoggingMinimumMegacyclesThreshold = 10 * 1200; // 10 seconds... } else if (costLoggingMinimumMegacyclesThreshold != newValue.longValue()) { logger.warn("changing cost logging to " + newValue + " megacycle threshold"); costLoggingMinimumMegacyclesThreshold = newValue; } } } catch (Exception e) { e.printStackTrace(); logger.error("exception while updating cost logging threshold: " + e.getMessage()); } } }
From source file:org.openmrs.module.reportingcompatibility.reporting.export.DataExportUtil.java
/** * Auto generated method comment/* w ww . jav a 2s.co m*/ * * @param dataExport * @param patientSet * @param functions * @param context * @throws Exception */ public static void generateExport(DataExportReportObject dataExport, Cohort patientSet, DataExportFunctions functions, EvaluationContext context) throws Exception { // defining log file here to attempt to reduce memory consumption Log log = LogFactory.getLog(DataExportUtil.class); VelocityEngine velocityEngine = new VelocityEngine(); velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.CommonsLogLogChute"); velocityEngine.setProperty(CommonsLogLogChute.LOGCHUTE_COMMONS_LOG_NAME, "dataexport_velocity"); try { velocityEngine.init(); } catch (Exception e) { log.error("Error initializing Velocity engine", e); } File file = getGeneratedFile(dataExport); PrintWriter report = new PrintWriter(file); VelocityContext velocityContext = new VelocityContext(); // Set up list of patients if one wasn't passed into this method if (patientSet == null) { patientSet = dataExport.generatePatientSet(context); functions.setPatientSet(patientSet); } String sizeGp = Context.getAdministrationService() .getGlobalProperty(ReportingCompatibilityConstants.BATCH_SIZE_GP); Integer batchSize = ReportingCompatibilityConstants.BATCH_SIZE_GP_DEFAULT; try { batchSize = Integer.parseInt(sizeGp); } catch (Exception e) { // Do nothing, just use the default } functions.setBatchSize(batchSize); // add the error handler EventCartridge ec = new EventCartridge(); ec.addEventHandler(new VelocityExceptionHandler()); velocityContext.attachEventCartridge(ec); // Set up velocity utils Locale locale = Context.getLocale(); velocityContext.put("locale", locale); velocityContext.put("fn", functions); /* * If we have any additional velocity objects that need to * be added, do so here. */ if (dataExportKeys != null && dataExportKeys.size() != 0) { for (Map.Entry<String, Object> entry : dataExportKeys.entrySet()) { velocityContext.put(entry.getKey(), entry.getValue()); } } velocityContext.put("patientSet", patientSet); String template = dataExport.generateTemplate(); // check if some deprecated columns are being used in this export // warning: hacky. if (template.contains("fn.getPatientAttr('Patient', 'tribe')")) { throw new APIException("Unable to generate export: " + dataExport.getName() + " because it contains a reference to an outdated 'tribe' column. You must install the 'Tribe Module' into OpenMRS to continue to reference tribes in OpenMRS."); } if (log.isDebugEnabled()) log.debug("Template: " + template.substring(0, template.length() < 3500 ? template.length() : 3500) + "..."); try { velocityEngine.evaluate(velocityContext, report, DataExportUtil.class.getName(), template); } catch (Exception e) { log.error("Error evaluating data export " + dataExport.getReportObjectId(), e); log.error("Template: " + template.substring(0, template.length() < 3500 ? template.length() : 3500) + "..."); report.print("\n\nError: \n" + e.toString() + "\n Stacktrace: \n"); e.printStackTrace(report); } finally { report.close(); velocityContext.remove("fn"); velocityContext.remove("patientSet"); velocityContext = null; // reset the ParserPool to something else now? // using this to get to RuntimeInstance.init(); velocityEngine.init(); velocityEngine = null; patientSet = null; functions.clear(); functions = null; template = null; dataExport = null; log.debug("Clearing hibernate session"); Context.clearSession(); // clear out the excess objects System.gc(); System.gc(); } }
From source file:org.openmrs.reporting.export.DataExportUtil.java
/** * Auto generated method comment// ww w. j a v a 2s . c om * * @param dataExport * @param patientSet * @param functions * @param context * @throws Exception */ public static void generateExport(DataExportReportObject dataExport, Cohort patientSet, DataExportFunctions functions, EvaluationContext context) throws Exception { // defining log file here to attempt to reduce memory consumption Log log = LogFactory.getLog(DataExportUtil.class); VelocityEngine velocityEngine = new VelocityEngine(); velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.CommonsLogLogChute"); velocityEngine.setProperty(CommonsLogLogChute.LOGCHUTE_COMMONS_LOG_NAME, "dataexport_velocity"); try { velocityEngine.init(); } catch (Exception e) { log.error("Error initializing Velocity engine", e); } File file = getGeneratedFile(dataExport); PrintWriter report = new PrintWriter(file); VelocityContext velocityContext = new VelocityContext(); // Set up list of patients if one wasn't passed into this method if (patientSet == null) { patientSet = dataExport.generatePatientSet(context); functions.setAllPatients(dataExport.isAllPatients()); } // add the error handler EventCartridge ec = new EventCartridge(); ec.addEventHandler(new VelocityExceptionHandler()); velocityContext.attachEventCartridge(ec); // Set up velocity utils Locale locale = Context.getLocale(); velocityContext.put("locale", locale); velocityContext.put("fn", functions); /* * If we have any additional velocity objects that need to * be added, do so here. */ if (dataExportKeys != null && dataExportKeys.size() != 0) { for (Map.Entry<String, Object> entry : dataExportKeys.entrySet()) { velocityContext.put(entry.getKey(), entry.getValue()); } } velocityContext.put("patientSet", patientSet); String template = dataExport.generateTemplate(); // check if some deprecated columns are being used in this export // warning: hacky. if (template.contains("fn.getPatientAttr('Patient', 'tribe')")) { throw new APIException("Unable to generate export: " + dataExport.getName() + " because it contains a reference to an outdated 'tribe' column. You must install the 'Tribe Module' into OpenMRS to continue to reference tribes in OpenMRS."); } if (log.isDebugEnabled()) log.debug("Template: " + template.substring(0, template.length() < 3500 ? template.length() : 3500) + "..."); try { velocityEngine.evaluate(velocityContext, report, DataExportUtil.class.getName(), template); } catch (Exception e) { log.error("Error evaluating data export " + dataExport.getReportObjectId(), e); log.error("Template: " + template.substring(0, template.length() < 3500 ? template.length() : 3500) + "..."); report.print("\n\nError: \n" + e.toString() + "\n Stacktrace: \n"); e.printStackTrace(report); } finally { report.close(); velocityContext.remove("fn"); velocityContext.remove("patientSet"); velocityContext = null; // reset the ParserPool to something else now? // using this to get to RuntimeInstance.init(); velocityEngine.init(); velocityEngine = null; patientSet = null; functions.clear(); functions = null; template = null; dataExport = null; log.debug("Clearing hibernate session"); Context.clearSession(); // clear out the excess objects System.gc(); System.gc(); } }
From source file:org.openmrs.web.Listener.java
/** * This method is called when the servlet context is initialized(when the Web Application is * deployed). You can initialize servlet context related data here. * * @param event// w w w. ja va2s.c o m */ @Override public void contextInitialized(ServletContextEvent event) { Log log = LogFactory.getLog(Listener.class); log.debug("Starting the OpenMRS webapp"); try { // validate the current JVM version OpenmrsUtil.validateJavaVersion(); ServletContext servletContext = event.getServletContext(); // pulled from web.xml. loadConstants(servletContext); // erase things in the dwr file clearDWRFile(servletContext); // Try to get the runtime properties Properties props = getRuntimeProperties(); if (props != null) { // the user has defined a runtime properties file setRuntimePropertiesFound(true); // set props to the context so that they can be // used during sessionFactory creation Context.setRuntimeProperties(props); } Thread.currentThread().setContextClassLoader(OpenmrsClassLoader.getInstance()); if (!setupNeeded()) { // must be done after the runtime properties are // found but before the database update is done copyCustomizationIntoWebapp(servletContext, props); //super.contextInitialized(event); // also see commented out line in contextDestroyed /** This logic is from ContextLoader.initWebApplicationContext. * Copied here instead of calling that so that the context is not cached * and hence not garbage collected */ XmlWebApplicationContext context = (XmlWebApplicationContext) createWebApplicationContext( servletContext); configureAndRefreshWebApplicationContext(context, servletContext); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); WebDaemon.startOpenmrs(event.getServletContext()); } else { setupNeeded = true; } } catch (Exception e) { setErrorAtStartup(e); log.fatal("Got exception while starting up: ", e); } }
From source file:org.openmrs.web.Listener.java
/** * Copy the customization scripts over into the webapp * * @param servletContext/*from www . ja v a 2 s .c om*/ */ private void copyCustomizationIntoWebapp(ServletContext servletContext, Properties props) { Log log = LogFactory.getLog(Listener.class); String realPath = servletContext.getRealPath(""); // TODO centralize map to WebConstants? Map<String, String> custom = new HashMap<String, String>(); custom.put("custom.template.dir", "/WEB-INF/template"); custom.put("custom.index.jsp.file", "/WEB-INF/view/index.jsp"); custom.put("custom.login.jsp.file", "/WEB-INF/view/login.jsp"); custom.put("custom.patientDashboardForm.jsp.file", "/WEB-INF/view/patientDashboardForm.jsp"); custom.put("custom.images.dir", "/images"); custom.put("custom.style.css.file", "/style.css"); custom.put("custom.messages", "/WEB-INF/custom_messages.properties"); custom.put("custom.messages_fr", "/WEB-INF/custom_messages_fr.properties"); custom.put("custom.messages_es", "/WEB-INF/custom_messages_es.properties"); custom.put("custom.messages_de", "/WEB-INF/custom_messages_de.properties"); for (Map.Entry<String, String> entry : custom.entrySet()) { String prop = entry.getKey(); String webappPath = entry.getValue(); String userOverridePath = props.getProperty(prop); // if they defined the variable if (userOverridePath != null) { String absolutePath = realPath + webappPath; File file = new File(userOverridePath); // if they got the path correct // also, if file does not start with a "." (hidden files, like SVN files) if (file.exists() && !userOverridePath.startsWith(".")) { log.debug("Overriding file: " + absolutePath); log.debug("Overriding file with: " + userOverridePath); if (file.isDirectory()) { for (File f : file.listFiles()) { userOverridePath = f.getAbsolutePath(); if (!f.getName().startsWith(".")) { String tmpAbsolutePath = absolutePath + "/" + f.getName(); if (!copyFile(userOverridePath, tmpAbsolutePath)) { log.warn("Unable to copy file in folder defined by runtime property: " + prop); log.warn("Your source directory (or a file in it) '" + userOverridePath + " cannot be loaded or destination '" + tmpAbsolutePath + "' cannot be found"); } } } } else { // file is not a directory if (!copyFile(userOverridePath, absolutePath)) { log.warn("Unable to copy file defined by runtime property: " + prop); log.warn("Your source file '" + userOverridePath + " cannot be loaded or destination '" + absolutePath + "' cannot be found"); } } } } } }
From source file:org.openmrs.web.Listener.java
/** * Load the pre-packaged modules from web/WEB-INF/bundledModules. <br> * <br>//from w ww . j a v a 2 s. c om * This method assumes that the api startup() and WebModuleUtil.startup() will be called later * for modules that loaded here * * @param servletContext the current servlet context for the webapp */ public static void loadBundledModules(ServletContext servletContext) { Log log = LogFactory.getLog(Listener.class); String path = servletContext.getRealPath(""); path += File.separator + "WEB-INF" + File.separator + "bundledModules"; File folder = new File(path); if (!folder.exists()) { log.warn("Bundled module folder doesn't exist: " + folder.getAbsolutePath()); return; } if (!folder.isDirectory()) { log.warn("Bundled module folder isn't really a directory: " + folder.getAbsolutePath()); return; } // loop over the modules and load the modules that we can for (File f : folder.listFiles()) { if (!f.getName().startsWith(".")) { // ignore .svn folder and the like try { Module mod = ModuleFactory.loadModule(f); log.debug("Loaded bundled module: " + mod + " successfully"); } catch (Exception e) { log.warn("Error while trying to load bundled module " + f.getName() + "", e); } } } }
From source file:org.openoss.tip.ri.NetworkServices.java
/** * setter for log//from ww w .j av a 2 s . c om * @param Log to use for log messages from this class */ @javax.annotation.Resource(name = "tipInterfaceLog") public void setLog(Log log) { if (log == null) throw new java.lang.IllegalArgumentException("ERROR: " + this.getClass().getSimpleName() + " method: setLog(Log log): Parameter log must not be null"); this.log = log; if (log.isDebugEnabled()) log.debug("DEBUG: " + this.getClass().getSimpleName() + ": Log set successfully for this class"); }
From source file:org.openspaces.grid.gsm.machines.MachinesSlaUtils.java
public static Collection<GridServiceAgent> sortAndFilterAgents(GridServiceAgent[] agents, ElasticMachineProvisioningConfig machineProvisioningConfig, Log logger) { Set<GridServiceAgent> filteredAgents = new LinkedHashSet<GridServiceAgent>(); //maintain order for (final GridServiceAgent agent : agents) { if (!agent.isDiscovered()) { if (logger.isDebugEnabled()) { logger.debug( "Agent " + MachinesSlaUtils.machineToString(agent.getMachine()) + " has shutdown."); }/*from w w w . j a va2 s . c o m*/ } else if (!MachinesSlaUtils.isAgentConformsToMachineProvisioningConfig(agent, machineProvisioningConfig)) { if (logger.isDebugEnabled()) { agent.getExactZones().isStasfies(machineProvisioningConfig.getGridServiceAgentZones()); ExactZonesConfig agentZones = agent.getExactZones(); ZonesConfig puZones = machineProvisioningConfig.getGridServiceAgentZones(); boolean isDedicatedManagedmentMachines = machineProvisioningConfig .isDedicatedManagementMachines(); boolean isManagementRunningOnMachine = MachinesSlaUtils .isManagementRunningOnMachine(agent.getMachine()); StringBuilder logMessage = new StringBuilder(); logMessage.append("Agent ").append(MachinesSlaUtils.machineToString(agent.getMachine())) .append(" does not conform to machine provisioning SLA. ").append("Agent zones: ") .append(agentZones).append(",").append("PU zones: ").append(puZones).append(", ") .append("Is dedicated management machines: ").append(isDedicatedManagedmentMachines) .append(", ").append("Is management running on machine: ") .append(isManagementRunningOnMachine); logger.debug(logMessage.toString()); } } else { if (logger.isTraceEnabled()) { logger.trace("Agent " + MachinesSlaUtils.machineToString(agent.getMachine()) + " conforms to machine provisioning SLA."); } filteredAgents.add(agent); } } //TODO: Move this sort into the bin packing solver. It already has the priority of each machine // so it can sort it by itself. final List<GridServiceAgent> sortedFilteredAgents = MachinesSlaUtils.sortManagementFirst(filteredAgents); if (logger.isDebugEnabled()) { logger.debug("Provisioned Agents: " + MachinesSlaUtils.machinesToString(sortedFilteredAgents)); } return sortedFilteredAgents; }