List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory.java
/** * Static method returning an implementation instance of this factory. * @return the factory singleton/*from w w w . ja v a 2 s .co m*/ */ public static IntegrationContextFactory getInstance() { Log log = LogFactory.getLog(IntegrationContextFactory.class); log.debug("IntegrationContextFactory.getInstance()"); if (instance == null) { try { FactoryUtil.setUseLocator(true); instance = FactoryUtil.lookup(); } catch (Exception ex) { log.error("Unable to read integration context: " + ex); } } log.debug("instance=" + instance); return instance; }
From source file:org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory.java
public static IntegrationContextFactory getTestInstance() { Log log = LogFactory.getLog(IntegrationContextFactory.class); log.debug("IntegrationContextFactory.getTestInstance()"); if (instance == null) { try {/*from w ww .j ava 2 s. c o m*/ FactoryUtil.setUseLocator(false); instance = FactoryUtil.lookup(); } catch (Exception ex) { log.error("Unable to read integration context: " + ex); } } log.debug("instance=" + instance); return instance; }
From source file:org.sigmah.server.schedule.export.AutoDeleteJob.java
public void execute(JobExecutionContext executionContext) throws JobExecutionException { final JobDataMap dataMap = executionContext.getJobDetail().getJobDataMap(); final EntityManager em = (EntityManager) dataMap.get("em"); final Log log = (Log) dataMap.get("log"); final Injector injector = (Injector) dataMap.get("injector"); EntityTransaction tx = null;/*from w w w . ja v a 2 s. c o m*/ try { // Open transaction /* * NOTE: it is impossible to use @Transactional for this method * The reason is link{TransactionalInterceptor} gets EntityManager * from the injector; this is server thread, so, EM is out of scope */ tx = em.getTransaction(); tx.begin(); final GlobalExportDAO exportDAO = new GlobalExportHibernateDAO(em); final List<GlobalExportSettings> settings = exportDAO.getGlobalExportSettings(); for (final GlobalExportSettings setting : settings) { /* * Check for auto delete schedule */ //skip if no delete schedule is specified if (setting.getAutoDeleteFrequency() == null || setting.getAutoDeleteFrequency() < 1) continue; final Calendar scheduledCalendar = Calendar.getInstance(); // subtract months from current date scheduledCalendar.add(Calendar.MONTH, 0 - setting.getAutoDeleteFrequency().intValue()); // get older exports List<GlobalExport> exports = exportDAO.getOlderExports(scheduledCalendar.getTime(), setting.getOrganization()); //delete exports and their contents for (final GlobalExport export : exports) { final List<GlobalExportContent> contents = export.getContents(); for (GlobalExportContent content : contents) { em.remove(content); } em.remove(export); } } tx.commit(); log.info("Scheduled DELETE of global exports fired"); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); log.error("Scheduled global export job failed : " + ex.getMessage()); ex.printStackTrace(); } }
From source file:org.sigmah.server.schedule.export.AutoExportJob.java
public void execute(JobExecutionContext executionContext) throws JobExecutionException { final JobDataMap dataMap = executionContext.getJobDetail().getJobDataMap(); final EntityManager em = (EntityManager) dataMap.get("em"); final Log log = (Log) dataMap.get("log"); final Injector injector = (Injector) dataMap.get("injector"); EntityTransaction tx = null;/*from w ww . j a va 2s .c om*/ try { // Open transaction /* * NOTE: it is impossible to use @Transactional for this method * The reason is link{TransactionalInterceptor} gets EntityManager * from the injector which is out of scope */ tx = em.getTransaction(); tx.begin(); final GlobalExportDAO exportDAO = new GlobalExportHibernateDAO(em); final GlobalExportDataProvider dataProvider = injector.getInstance(GlobalExportDataProvider.class); final List<GlobalExportSettings> settings = exportDAO.getGlobalExportSettings(); for (final GlobalExportSettings setting : settings) { /* * Check for auto export schedule */ //skip if no export schedule is specified if (setting.getAutoExportFrequency() == null || setting.getAutoExportFrequency() < 1) continue; final Calendar systemCalendar = Calendar.getInstance(); boolean doExport = false; if ((setting.getAutoExportFrequency() >= 31) && (setting.getAutoExportFrequency() <= 58)) { //Case of Monthly Auto Export if ((setting.getAutoExportFrequency() - 30) == systemCalendar.get(Calendar.DAY_OF_MONTH)) { doExport = true; } } else if ((setting.getAutoExportFrequency() >= 61) && (setting.getAutoExportFrequency() <= 67)) { //Case of Weekly Auto Export if ((setting.getAutoExportFrequency() - 60) == systemCalendar.get(Calendar.DAY_OF_WEEK)) { doExport = true; } } else { //Regular Auto-Export every N-days final Calendar scheduledCalendar = Calendar.getInstance(); Date lastExportDate = setting.getLastExportDate(); if (lastExportDate == null) { lastExportDate = systemCalendar.getTime(); setting.setLastExportDate(lastExportDate); em.merge(setting); } else { scheduledCalendar.setTime(lastExportDate); // add scheduled days to the last exported date scheduledCalendar.add(Calendar.DAY_OF_MONTH, setting.getAutoExportFrequency()); } final Date systemDate = getZeroTimeDate(systemCalendar.getTime()); final Date scheduledDate = getZeroTimeDate(scheduledCalendar.getTime()); if (systemDate.compareTo(scheduledDate) >= 0) { doExport = true; } } if (doExport) { /* * Start auto export */ // persist global export logger final GlobalExport globalExport = new GlobalExport(); globalExport.setOrganization(setting.getOrganization()); globalExport.setDate(systemCalendar.getTime()); em.persist(globalExport); // generate export content final Map<String, List<String[]>> exportData = dataProvider .generateGlobalExportData(setting.getOrganization().getId(), em, setting.getLocale()); // persist export content dataProvider.persistGlobalExportDataAsCsv(globalExport, em, exportData); } } tx.commit(); log.info("Scheduled EXPORT of global exports fired"); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); log.error("Scheduled global export job failed : " + ex.getMessage()); ex.printStackTrace(); } }
From source file:org.soaplab.share.SoaplabException.java
/****************************************************************************** * Format given exception 'e' depending on how serious it it. In * same cases add stack trace. Log the result in the given * 'log'. <p>/*from w w w . j av a 2s.c o m*/ * * @param e an exception to be formatted and logged * @param log where to log it * ******************************************************************************/ public static void formatAndLog(Throwable e, org.apache.commons.logging.Log log) { boolean seriousError = (e instanceof java.lang.RuntimeException); if (seriousError || log.isDebugEnabled()) { StringWriter sw = new StringWriter(500); e.printStackTrace(new PrintWriter(sw)); if (seriousError) log.error(sw.toString()); else log.debug(sw.toString()); } else { log.error(e.getMessage()); } }
From source file:org.springframework.util.Log4jConfigurerTests.java
private void doTestInitLogging(String location, boolean refreshInterval) throws FileNotFoundException { if (refreshInterval) { Log4jConfigurer.initLogging(location, 10); } else {/*from w ww. j a v a 2 s . co m*/ Log4jConfigurer.initLogging(location); } Log log = LogFactory.getLog(this.getClass()); log.debug("debug"); log.info("info"); log.warn("warn"); log.error("error"); log.fatal("fatal"); assertTrue(MockLog4jAppender.loggingStrings.contains("debug")); assertTrue(MockLog4jAppender.loggingStrings.contains("info")); assertTrue(MockLog4jAppender.loggingStrings.contains("warn")); assertTrue(MockLog4jAppender.loggingStrings.contains("error")); assertTrue(MockLog4jAppender.loggingStrings.contains("fatal")); Log4jConfigurer.shutdownLogging(); assertTrue(MockLog4jAppender.closeCalled); }
From source file:org.springframework.util.Log4jConfigurerTestSuite.java
public void testInitLoggingString() throws FileNotFoundException { try {// ww w. j a va 2 s . c o m Log4jConfigurer.initLogging("test/org/springframework/util/bla.properties"); fail("Exception should have been thrown, file does not exist!"); } catch (FileNotFoundException e) { // ok } Log4jConfigurer.initLogging("test/org/springframework/util/testlog4j.properties"); Log log = LogFactory.getLog(this.getClass()); log.debug("debug"); log.info("info"); log.warn("warn"); log.error("error"); log.fatal("fatal"); assertTrue(MockLog4jAppender.loggingStrings.contains("debug")); assertTrue(MockLog4jAppender.loggingStrings.contains("info")); assertTrue(MockLog4jAppender.loggingStrings.contains("warn")); assertTrue(MockLog4jAppender.loggingStrings.contains("error")); assertTrue(MockLog4jAppender.loggingStrings.contains("fatal")); }
From source file:org.springframework.web.util.Log4jWebConfigurerTests.java
private void assertLogOutput() { Log log = LogFactory.getLog(this.getClass()); log.debug("debug"); log.info("info"); log.warn("warn"); log.error("error"); log.fatal("fatal"); assertTrue(MockLog4jAppender.loggingStrings.contains("debug")); assertTrue(MockLog4jAppender.loggingStrings.contains("info")); assertTrue(MockLog4jAppender.loggingStrings.contains("warn")); assertTrue(MockLog4jAppender.loggingStrings.contains("error")); assertTrue(MockLog4jAppender.loggingStrings.contains("fatal")); }
From source file:org.swordess.ldap.util.LogUtils.java
public static void error(Log log, Object message) { if (log.isErrorEnabled()) { log.error(message); } }
From source file:org.talframework.tal.aspects.loggers.trace.DefaultExceptionLogger.java
/** * Logs out that the method has failed listing out the full * input parameters and the exception. Logging is done as * error level/* ww w . j a v a2s. com*/ */ public void traceException(JoinPoint jp, Throwable t) { Log traceLogger = LoggerHelper.getLogger(jp.getStaticPart().getSignature().getDeclaringType()); StringBuilder builder = new StringBuilder(); builder.append("!!! Error From: ").append(jp.getStaticPart().getSignature().getName()); builder.append("\n\texception=").append(t); LoggerHelper.appendArguments(jp.getArgs(), builder); traceLogger.error(builder.toString()); if (traceLogger.isDebugEnabled()) t.printStackTrace(); }