List of usage examples for org.apache.commons.logging Log warn
void warn(Object message, Throwable t);
From source file:org.displaytag.exception.BaseNestableJspTagException.java
/** * Instantiate a new BaseNestableJspTagException. * @param source Class where the exception is generated * @param message message//from w w w . j a v a 2 s. c o m * @param cause previous Exception */ public BaseNestableJspTagException(Class source, String message, Throwable cause) { super(message); this.sourceClass = source; this.nestedException = cause; // log exception Log log = LogFactory.getLog(source); // choose appropriate logging method if (getSeverity() == SeverityEnum.DEBUG) { log.debug(toString(), cause); } else if (getSeverity() == SeverityEnum.INFO) { log.info(toString(), cause); } else if (getSeverity() == SeverityEnum.WARN) { log.warn(toString(), cause); } else { // error - default log.error(toString(), cause); } }
From source file:org.displaytag.exception.BaseNestableRuntimeException.java
/** * Instantiate a new BaseNestableRuntimeException. * @param source Class where the exception is generated * @param message message// ww w. java 2 s. c om * @param cause previous Exception */ public BaseNestableRuntimeException(Class source, String message, Throwable cause) { super(message); this.sourceClass = source; this.nestedException = cause; // log exception Log log = LogFactory.getLog(source); // choose appropriate logging method if (getSeverity() == SeverityEnum.DEBUG) { log.debug(toString(), cause); } else if (getSeverity() == SeverityEnum.INFO) { log.info(toString(), cause); } else if (getSeverity() == SeverityEnum.WARN) { log.warn(toString(), cause); } else { // error - default log.error(toString(), cause); } }
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 *///from w ww .j a v a 2 s .co 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.globus.gsi.jsse.GlobusSSLHelper.java
/** * Create a store of Certificate Revocation Lists. Java requires that this * be a java.security.certificates.CertStore. As such, the store can hold * both CRL's and non-trusted certs. For the purposes of this method, we * assume that only crl's will be loaded. This can only be used with the * Globus provided Certificate Store./*from w w w. jav a 2s .co m*/ * * @param crlPattern * The pattern which defines the locations of the CRL's * @return A configured Java CertStore containing the specified CRL's * @throws GlobusSSLConfigurationException * if the store cannot be loaded. */ public static CertStore findCRLStore(String crlPattern) throws GlobusSSLConfigurationException { try { return Stores.getCRLStore(crlPattern); } catch (InvalidAlgorithmParameterException e) { throw new GlobusSSLConfigurationException(e); } catch (NoSuchAlgorithmException e) { Log logger = LogFactory.getLog(GlobusSSLHelper.class.getCanonicalName()); logger.warn("Error Loading CRL store", e); throw new GlobusSSLConfigurationException(e); } catch (GeneralSecurityException e) { Log logger = LogFactory.getLog(GlobusSSLHelper.class.getCanonicalName()); logger.warn("Error Loading CRL store", e); throw new GlobusSSLConfigurationException(e); } }
From source file:org.hrva.capture.Capture.java
/** * Command-line program to tail a log and then push file to the HRT couch * DB.//w w w .j a v a 2 s .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 ww w. ja 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./*from w w w . jav 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(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.//from w ww.j a va 2s. c om * <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.jasig.portal.jmx.JavaManagementServerListener.java
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) *///w w w . j av a 2s. c o m public void contextInitialized(ServletContextEvent event) { Log logger = LogFactory.getLog(LOGGER_NAME); final ServletContext servletContext = event.getServletContext(); //Create the bean this.javaManagementServerBean = new JavaManagementServerBean(); //Get the failOnException option final String failOnExceptionStr = servletContext.getInitParameter(FAIL_ON_EXCEPTION); boolean failOnException = Boolean.parseBoolean(failOnExceptionStr); this.javaManagementServerBean.setFailOnException(failOnException); final String host = servletContext.getInitParameter(JMX_RMI_HOST); this.javaManagementServerBean.setHost(host); //Get the base rmi port from the init parameters final String portOneStr = servletContext.getInitParameter(JMX_RMI_PORT_1); try { final int portOne = Integer.parseInt(portOneStr); this.javaManagementServerBean.setPortOne(portOne); } catch (NumberFormatException nfe) { logger.warn("init-parameter '" + JMX_RMI_PORT_1 + "' is required and must contain a number. '" + portOneStr + "' is not a valid number.", nfe); } //Get the second rmi port from the init parameters final String portTwoStr = servletContext.getInitParameter(JMX_RMI_PORT_2); try { final int portTwo = Integer.parseInt(portTwoStr); this.javaManagementServerBean.setPortTwo(portTwo); } catch (NumberFormatException nfe) { logger.debug("Failed to convert init-parameter '" + JMX_RMI_PORT_2 + "' with value '" + portTwoStr + "' to a number, defaulting portTwo to portOne + 1", nfe); } this.javaManagementServerBean.startServer(); }
From source file:org.jboss.netty.logging.CommonsLoggerTest.java
@Test public void testWarnWithException() { org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class); mock.warn("a", e); replay(mock);/*from w w w .j ava 2s . c o m*/ InternalLogger logger = new CommonsLogger(mock, "foo"); logger.warn("a", e); verify(mock); }