Java Code Examples for org.apache.uima.util.Logger#setLevel()

The following examples show how to use org.apache.uima.util.Logger#setLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingTest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void testSetLevel() throws Exception {
  Logger uimaLogger = UIMAFramework.getLogger(); // should affect everything in
  // org.apache.uima.*
  try {

    // get class logger
    Logger logger = UIMAFramework.getLogger(this.getClass());

    // set level to WARNING
    uimaLogger.setLevel(Level.WARNING);
    Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
    Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
    Assert.assertFalse(uimaLogger.isLoggable(Level.INFO));
    Assert.assertTrue(logger.isLoggable(Level.WARNING));
    Assert.assertTrue(logger.isLoggable(Level.SEVERE));
    Assert.assertFalse(logger.isLoggable(Level.INFO));

    // set level to FINE
    uimaLogger.setLevel(Level.FINE);
    Assert.assertTrue(uimaLogger.isLoggable(Level.WARNING));
    Assert.assertTrue(uimaLogger.isLoggable(Level.SEVERE));
    Assert.assertTrue(uimaLogger.isLoggable(Level.INFO));
    Assert.assertFalse(uimaLogger.isLoggable(Level.FINER));
    Assert.assertFalse(uimaLogger.isLoggable(Level.ALL));
    Assert.assertTrue(logger.isLoggable(Level.WARNING));
    Assert.assertTrue(logger.isLoggable(Level.SEVERE));
    Assert.assertTrue(logger.isLoggable(Level.INFO));
    Assert.assertFalse(logger.isLoggable(Level.FINER));
    Assert.assertFalse(logger.isLoggable(Level.ALL));
  } catch (Exception ex) {
    JUnitExtension.handleException(ex);
  } finally {
    uimaLogger.setLevel(Level.INFO); // otherwise, is stuck at INFO, too much logging
  }

}