List of usage examples for org.apache.commons.logging Log fatal
void fatal(Object message, Throwable t);
From source file:org.easyrec.utils.spring.log.LoggerUtils.java
/** * Writes the given 'message' to the Log 'logger' with level 'logLevel'. * * @param logger the Log to which the message is written * @param logLevel the level to which the message is written * @param message the message to be written * @param ta a Throwable passed on to the Log *//* w w w . jav a2s . c o m*/ public static void log(Log logger, String logLevel, String message, Throwable ta) { if (logLevel.equalsIgnoreCase("info")) { if (logger.isInfoEnabled()) { logger.info(message, ta); } } else if (logLevel.equalsIgnoreCase("debug")) { if (logger.isDebugEnabled()) { logger.debug(message, ta); } } else if (logLevel.equalsIgnoreCase("error")) { if (logger.isErrorEnabled()) { logger.error(message, ta); } } else if (logLevel.equalsIgnoreCase("trace")) { if (logger.isTraceEnabled()) { logger.trace(message, ta); } } else if (logLevel.equalsIgnoreCase("warn")) { if (logger.isWarnEnabled()) { logger.warn(message, ta); } } else if (logLevel.equalsIgnoreCase("fatal")) { if (logger.isFatalEnabled()) { logger.fatal(message, ta); } } else { logger.error("Passed unknown log level " + logLevel + " to Aspect - logging to error instead!"); logger.error(message, ta); } }
From source file:org.eclipse.gemini.blueprint.util.LogUtils.java
private static Log doCreateLogger(Class<?> logName) { Log logger; ClassLoader ccl = Thread.currentThread().getContextClassLoader(); // push the logger class classloader (useful when dealing with commons-logging 1.0.x Thread.currentThread().setContextClassLoader(logName.getClassLoader()); try {//from w ww. ja v a 2s .c om logger = LogFactory.getLog(logName); } catch (Throwable th) { logger = new SimpleLogger(); logger.fatal( "logger infrastructure not properly set up. If commons-logging jar is used try switching to slf4j (see the FAQ for more info).", th); } finally { Thread.currentThread().setContextClassLoader(ccl); } return logger; }
From source file:org.gcaldaemon.core.Configurator.java
private final Thread startService(Log log, ThreadGroup group, String name) throws Exception { try {// ww w. j a va2 s . c om Class serviceClass = Class.forName(name); Class[] types = new Class[2]; types[0] = ThreadGroup.class; types[1] = Configurator.class; Constructor constructor = serviceClass.getConstructor(types); Object[] values = new Object[2]; values[0] = group; values[1] = this; return (Thread) constructor.newInstance(values); } catch (Exception configError) { String message = configError.getMessage(); Throwable cause = configError.getCause(); while (cause != null) { if (cause.getMessage() != null) { message = cause.getMessage(); } cause = cause.getCause(); } log.fatal(message.toUpperCase(), configError); throw configError; } }
From source file:org.hrva.capture.Capture.java
/** * Command-line program to tail a log and then push file to the HRT couch * DB.//from w ww . j a v a 2s. com * * <p>All this does is read properties and invoke run_main</p> * * @param args arguments */ public static void main(String[] args) { Log log = LogFactory.getLog(Reformat.class); File prop_file = new File("hrtail.properties"); Properties config = new Properties(); try { config.load(new FileInputStream(prop_file)); } catch (IOException ex) { log.warn("Can't find " + prop_file.getName(), ex); try { log.debug(prop_file.getCanonicalPath()); } catch (IOException ex1) { } } Capture capture = new Capture(config); try { capture.run_main(args); } catch (CmdLineException ex1) { log.fatal("Invalid Options", ex1); } catch (MalformedURLException ex2) { log.fatal("Invalid CouchDB URL", ex2); } catch (IOException ex3) { log.fatal(ex3); } }
From source file:org.hrva.capture.CouchPush.java
/** * Command-line program to push a file to the HRT couch DB. * <p>All this does is read properties and invoke run_main</p> * @param args arguments/*from www . j a v a 2 s. c om*/ */ public static void main(String[] args) { Log log = LogFactory.getLog(CouchPush.class); File prop_file = new File("hrtail.properties"); Properties config = new Properties(); try { config.load(new FileInputStream(prop_file)); } catch (IOException ex) { log.warn("Can't find " + prop_file.getName(), ex); try { log.debug(prop_file.getCanonicalPath()); } catch (IOException ex1) { } } CouchPush cp = new CouchPush(config); try { cp.run_main(args); } catch (CmdLineException ex1) { log.fatal("Invalid Options", ex1); } catch (MalformedURLException ex2) { log.fatal("Invalid CouchDB URL", ex2); } catch (IOException ex3) { log.fatal(ex3); } }
From source file:org.hrva.capture.LogTail.java
/** * Command-line program to tail a log and then push file to the HRT couch * DB./* w w w.j a va 2 s . c o m*/ * <p>All this does is read properties and invoke run_main</p> * * @param args arguments */ public static void main(String[] args) { Log log = LogFactory.getLog(LogTail.class); File prop_file = new File("hrtail.properties"); Properties config = new Properties(); try { config.load(new FileInputStream(prop_file)); } catch (IOException ex) { log.warn("Can't find " + prop_file.getName(), ex); try { log.debug(prop_file.getCanonicalPath()); } catch (IOException ex1) { } } LogTail lt = new LogTail(config); try { lt.run_main(args); } catch (CmdLineException ex1) { log.fatal("Invalid Options", ex1); } catch (MalformedURLException ex2) { log.fatal("Invalid CouchDB URL", ex2); } catch (IOException ex3) { log.fatal(ex3); } }
From source file:org.hrva.capture.Reformat.java
/** * Command-line program to tail a log and then push file to the HRT couch * DB.//w ww .j a v a 2 s .c o m * <p>All this does is read properties and invoke run_main</p> * * @param args arguments */ public static void main(String[] args) { Log log = LogFactory.getLog(Reformat.class); File prop_file = new File("hrtail.properties"); Properties config = new Properties(); try { config.load(new FileInputStream(prop_file)); } catch (IOException ex) { log.warn("Can't find " + prop_file.getName(), ex); try { log.debug(prop_file.getCanonicalPath()); } catch (IOException ex1) { } } Reformat fmt = new Reformat(config); try { fmt.run_main(args); } catch (CmdLineException ex1) { log.fatal("Invalid Options", ex1); } catch (MalformedURLException ex2) { log.fatal("Invalid CouchDB URL", ex2); } catch (IOException ex3) { log.fatal(ex3); } }
From source file:org.java.plugin.ObjectFactory.java
/** * Creates and configures new instance of object factory. Factory * implementation class discovery procedure is following: * <ul>//from w ww . j a v a2s .co m * <li>Use the <code>org.java.plugin.ObjectFactory</code> property from * the given properties collection (if it is provided).</li> * <li>Use the <code>org.java.plugin.ObjectFactory</code> system * property.</li> * <li>Use the properties file "jpf.properties" in the JRE "lib" * directory or in the CLASSPATH. This configuration file is in standard * <code>java.util.Properties</code> format and contains among others the * fully qualified name of the implementation class with the key being the * system property defined above.</li> * <li>Use the Services API (as detailed in the JAR specification), if * available, to determine the class name. The Services API will look for * a class name in the file * <code>META-INF/services/org.java.plugin.ObjectFactory</code> in jars * available to the runtime.</li> * <li>Framework default <code>ObjectFactory</code> implementation.</li> * </ul> * @param config factory configuration data, may be <code>null</code> * @return configured instance of object factory */ public static ObjectFactory newInstance(final ExtendedProperties config) { Log log = LogFactory.getLog(ObjectFactory.class); ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ObjectFactory.class.getClassLoader(); } ExtendedProperties props; if (config != null) { props = config; } else { props = loadProperties(cl); } String className = findProperty(cl, props); ObjectFactory result; try { if (className == null) { className = "org.java.plugin.standard.StandardObjectFactory"; //$NON-NLS-1$ } result = (ObjectFactory) loadClass(cl, className).newInstance(); } catch (ClassNotFoundException cnfe) { log.fatal("failed instantiating object factory " //$NON-NLS-1$ + className, cnfe); throw new Error("failed instantiating object factory " //$NON-NLS-1$ + className, cnfe); } catch (IllegalAccessException iae) { log.fatal("failed instantiating object factory " //$NON-NLS-1$ + className, iae); throw new Error("failed instantiating object factory " //$NON-NLS-1$ + className, iae); } catch (SecurityException se) { log.fatal("failed instantiating object factory " //$NON-NLS-1$ + className, se); throw new Error("failed instantiating object factory " //$NON-NLS-1$ + className, se); } catch (InstantiationException ie) { log.fatal("failed instantiating object factory " //$NON-NLS-1$ + className, ie); throw new Error("failed instantiating object factory " //$NON-NLS-1$ + className, ie); } result.configure(props); log.debug("object factory instance created - " + result); //$NON-NLS-1$ return result; }
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 . j a v a 2 s . c om 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
/** * 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//from ww w . j a v a 2s . c om */ @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); } }