Java Code Examples for java.util.logging.StreamHandler#setLevel()

The following examples show how to use java.util.logging.StreamHandler#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: TopLogging.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static synchronized Handler streamHandler() {
    if (streamHandler == null) {
        StreamHandler sth = new StreamHandler (OLD_ERR, NbFormatter.FORMATTER);
        sth.setLevel(Level.ALL);
        streamHandler = NbLogging.createDispatchHandler(sth, 500);
    }
    return streamHandler;
}
 
Example 2
Source File: CatalogModelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDepResolver() throws URISyntaxException, CatalogModelException, IOException {
    
    Logger logger = Logger.getLogger(CatalogModelTest.class.getName());
    logger.setLevel(Level.ALL);
    StreamHandler sh = new MyHandler(System.out, new SimpleFormatter());
    sh.setLevel(logger.getLevel());
    //logger.addHandler(sh);
    CatalogFileWrapperDOMImpl.TEST_ENVIRONMENT = true;
    File catFile = new File(System.getProperty("java.io.tmpdir")+File.separator+CatalogWriteModel.PUBLIC_CATALOG_FILE_NAME+CatalogWriteModel.CATALOG_FILE_EXTENSION+".girish");
    catFile.delete();
    catFile.createNewFile();
    FileObject catFO = FileUtil.toFileObject(FileUtil.normalizeFile(catFile));
    URL url = getClass().getResource("dummyFile.txt");
    FileObject peerfo = FileUtil.toFileObject(new File(url.toURI()).getAbsoluteFile());
    System.out.println(catFile);
    CatalogWriteModel drz = new MyCatalogWriteModel(catFO);
    //CatalogWriteModel drz = new MyCatalogWriteModel(new File(System.getProperty("java.io.tmpdir")));
    drz.addURI(new URI("dummy/dummy"), peerfo);
    int length = drz.getCatalogEntries().size();
    
    assertEquals(1, length);
    
    //System.out.println("%%%%"+drz.getModelSource(new URI("dummy/dummy")).getFileObject());
    
    //System.out.println("$$$$"+LSResourceResolverFactory.getDefault().resolveResource(null, null, null, "dummy/dummy", url.toURI().toString()).getSystemId());
    
    //assertTrue(LSResourceResolverFactory.getDefault().resolveResource(null, null, null, "dummy/dummy", url.toURI().toString()).getSystemId().endsWith("dummyFile.txt"));
    
    FileObject fob = (FileObject) drz.getModelSource(new URI("dummy/dummy")).getLookup().lookup(FileObject.class);
    
    assertNotNull(fob);
    
    drz.removeURI(new URI("dummy/dummy"));
    
    length = drz.getCatalogEntries().size();
    
    assertEquals(0, length);
}
 
Example 3
Source File: LoggerTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Set up logger
 */
@Before
public void before() {
    fLogger = Logger.getAnonymousLogger();
    fLog = new StringOutputStream();
    fStreamHandler = new StreamHandler(fLog, new SimpleFormatter());
    fStreamHandler.setLevel(Level.FINER);
    fLogger.setLevel(Level.ALL);
    fLogger.addHandler(fStreamHandler);
}
 
Example 4
Source File: LoggingMediaHttpUploaderProgressListenerTest.java    From hadoop-connectors with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  listener = new LoggingMediaHttpUploaderProgressListener("NAME", 60000L);

  jdkLoggerForConfig.setLevel(Level.FINE);
  logCapturingStream = new ByteArrayOutputStream();
  customLogHandler = new StreamHandler(logCapturingStream, LOG_FORMATTER);
  customLogHandler.setLevel(Level.FINE);
  jdkLoggerForConfig.addHandler(customLogHandler);
}
 
Example 5
Source File: EngintTaskLoggerTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void testLogger( ) throws Exception
{
	Logger engineLogger = Logger.getAnonymousLogger( );
	ByteArrayOutputStream engineOut = new ByteArrayOutputStream( );
	StreamHandler engineHandler = new StreamHandler( engineOut,
			new SimpleFormatter( ) );
	engineHandler.setLevel( Level.ALL );
	engineLogger.addHandler( engineHandler );
	engineLogger.setLevel( Level.ALL );

	Logger taskLogger = Logger.getAnonymousLogger();
	ByteArrayOutputStream taskOut = new ByteArrayOutputStream( );
	StreamHandler taskHandler = new StreamHandler( taskOut,
			new SimpleFormatter( ) );
	taskHandler.setLevel( Level.ALL );
	taskLogger.addHandler( taskHandler );
	taskLogger.setLevel( Level.ALL );

	engine.setLogger( engineLogger );
	engine.changeLogLevel( Level.ALL );

	engineHandler.flush( );
	taskHandler.flush( );

	new File( "./utest/" ).mkdirs( );
	copyResource(
			"org/eclipse/birt/report/engine/api/engine-task-logger-test.rptdesign",
			"./utest/reportdesign.rptdesign" );
	IReportRunnable runnable = engine
			.openReportDesign( "./utest/reportdesign.rptdesign" );

	IRunTask task = engine.createRunTask( runnable );
	task.setParameter( "sample", "==golden values==", "displayText" );
	task.run( "./utest/report.rptdocument" );
	task.close( );

	// the logger is output to engine out.
	engineHandler.flush( );
	assertTrue( engineOut.toString( ).indexOf( "==golden values==" ) != -1 );
	engineOut.reset( );

	task = engine.createRunTask( runnable );
	task.setLogger( taskLogger );
	task.setParameter( "sample", "==golden values==", "displayText" );
	task.run( "./utest/report.rptdocument" );
	task.close( );

	engineHandler.flush( );
	taskHandler.flush( );
	assertTrue( engineOut.toString( ).indexOf( "==golden values==" ) == -1 );
	assertTrue( taskOut.toString( ).indexOf( "==golden values==" ) != -1 );
}