当前位置: 首页>>代码示例>>Java>>正文


Java Logger.removeHandler方法代码示例

本文整理汇总了Java中java.util.logging.Logger.removeHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.removeHandler方法的具体用法?Java Logger.removeHandler怎么用?Java Logger.removeHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Logger的用法示例。


在下文中一共展示了Logger.removeHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: throwingOnFailLogs

import java.util.logging.Logger; //导入方法依赖的package包/类
@Ignore("AsyncCall currently lets runtime exceptions propagate.")
@Test public void throwingOnFailLogs() throws InterruptedException {
  TestLogHandler logs = new TestLogHandler();
  Logger logger = Logger.getLogger(OkHttpClient.class.getName());
  logger.addHandler(logs);

  webServer.enqueue(new MockResponse().setResponseCode(200).setBody("Body"));

  final RuntimeException e = new RuntimeException();
  clientListener.setNextEventDelegate(new WebSocketListener() {
    @Override public void onFailure(WebSocket webSocket, Throwable t, Response response) {
      throw e;
    }
  });

  newWebSocket();

  assertEquals("", logs.take());
  logger.removeHandler(logs);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:WebSocketHttpTest.java

示例2: tearDown

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
    final RepositoryUpdaterTest.TestHandler handler = new RepositoryUpdaterTest.TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests"); //NOI18N
    try {
        logger.setLevel (Level.FINEST);
        logger.addHandler(handler);
        for(String id : registeredClasspaths.keySet()) {
            final Map<ClassPath,Void> classpaths = registeredClasspaths.get(id);
            GlobalPathRegistry.getDefault().unregister(id, classpaths.keySet().toArray(new ClassPath[classpaths.size()]));
        }
        handler.await();
    } finally {
        logger.removeHandler(handler);
    }
    super.tearDown();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:VisibilityChangeTest.java

示例3: testEmbeddingIndexerOrdering

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testEmbeddingIndexerOrdering() throws InterruptedException {
    assertTrue(GlobalPathRegistry.getDefault().getPaths(SRC_EMB).isEmpty());
    final RepositoryUpdaterTest.TestHandler handler = new RepositoryUpdaterTest.TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests"); //NOI18N
    logger.setLevel (Level.FINEST);
    logger.addHandler(handler);
    try {
        final ClassPath cp = ClassPathSupport.createClassPath(eroot);
        calls.clear();
        globalPathRegistry_register(SRC_EMB, new ClassPath[]{cp});
        assertTrue (handler.await());
        assertEquals(5, calls.size());
        final Iterator<SourceIndexerFactory> callsIt = calls.iterator();
        for (int i=1; i<=5; i++) {
            assertEquals(
                String.format("EI%d",i),    //NOI18N
                callsIt.next().getIndexerName());
        }
        
    } finally {
        logger.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:IndexerOrderingTest.java

示例4: doClose

import java.util.logging.Logger; //导入方法依赖的package包/类
public final void doClose() {
    Logger log = Logger.getLogger(UI_LOGGER_NAME);
    log.removeHandler(ui);
    uiLogger = null;
    Logger all = Logger.getLogger(""); // NOI18N
    all.removeHandler(handler);
    allLogger = null;
    log = Logger.getLogger(METRICS_LOGGER_NAME);
    log.removeHandler(metrics);
    metricsLogger = null;

    closeLogStream();
    closeLogStreamMetrics();
    synchronized (restored) {
        restored.set(false);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Installer.java

示例5: testLimitAddWatchLogs

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testLimitAddWatchLogs() throws IOException {
    FileObject root = FileUtil.toFileObject(getWorkDir());
    int total = 100;

    Logger log = Logger.getLogger(Watcher.class.getName());
    Log.enable(log.getName(), Level.FINEST);
    LogCountHandler h = new LogCountHandler();

    log.addHandler(h);
    try {
        for (int i = 0; i < total; i++) {
            root.addFileChangeListener(listener);
        }
    } finally {
        log.removeHandler(h);
    }

    assertEquals("2 warnings", 2, h.warning);
    assertEquals("10 infos", 10, h.info);
    assertEquals("The rest messages are of fine level", 88, h.fine);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:WatcherLoggingTest.java

示例6: testOverridenGetTargetNames

import java.util.logging.Logger; //导入方法依赖的package包/类
@Test
public void testOverridenGetTargetNames() throws Exception {
    assertNotNull(ap);
    final Logger log = Logger.getLogger(ActionProviderSupport.class.getName());
    final Level origLevel = log.getLevel();
    final MockHandler handler = new MockHandler();
    log.setLevel(Level.FINE);
    log.addHandler(handler);
    try {
        SwingUtilities.invokeAndWait(() -> {
            ap.invokeAction(ActionProvider.COMMAND_CLEAN, Lookup.EMPTY);
        });
        assertEquals("1", handler.props.get("a"));      //NOI18N
        assertEquals("2", handler.props.get("b"));      //NOI18N
    } finally {
        log.setLevel(origLevel);
        log.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:BaseActionProviderTest.java

示例7: tearDown

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
    final TestHandler handler = new TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests");
    try {
        logger.setLevel (Level.FINEST);
        logger.addHandler(handler);
        for(String id : registeredClasspaths.keySet()) {
            final Map<ClassPath,Void> classpaths = registeredClasspaths.get(id);
            GlobalPathRegistry.getDefault().unregister(id, classpaths.keySet().toArray(new ClassPath[classpaths.size()]));
        }
        handler.await();
    } finally {
        logger.removeHandler(handler);
    }
    super.tearDown();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RepositoryUpdaterTest.java

示例8: testScanProjects

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testScanProjects() throws Exception {
    File projectsDir = getWorkDir();
    for (String projectName : Utilities.PROJECTS.keySet()) {
        Utilities.projectDownloadAndUnzip(projectName, projectsDir);
    }
    Logger repositoryUpdater = Logger.getLogger(RepositoryUpdater.class.getName());
    repositoryUpdater.setLevel(Level.INFO);
    handler = new ScanningHandler("test projects", 70000, 140000, 1000, 15000);
    repositoryUpdater.addHandler(handler);

    Logger log = Logger.getLogger("org.openide.filesystems.MIMESupport");
    log.setLevel(Level.WARNING);
    Utilities.ReadingHandler readHandler = new Utilities.ReadingHandler();
    log.addHandler(readHandler);

    Utilities.openProjects(projectsDir, Utilities.PROJECTS.keySet().toArray(new String[0]));
    Utilities.waitScanningFinished(projectsDir);
    handler.setType(ScanningHandler.ScanType.UP_TO_DATE);
    Utilities.refreshIndexes();
    Utilities.waitScanningFinished(projectsDir);
    OpenProjects.getDefault().close(OpenProjects.getDefault().getOpenProjects());
    repositoryUpdater.removeHandler(handler);
    // wait for scanning of unowned roots after all projects are closed
    synchronized(this) {
        this.wait(10000);
}
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ScanSeveralProjectsPerfTest.java

示例9: testFolderAlreadyExists152219

import java.util.logging.Logger; //导入方法依赖的package包/类
/** Test recovery of FileUtil.createFolder(FileObject, String) method when
 * other thread created folder in the middle of processing (see #152219).
 */
public void testFolderAlreadyExists152219() {
    final FileObject folder = FileUtil.createMemoryFileSystem().getRoot();
    final String name = "subfolder";
    Handler handler = new Handler() {

        @Override
        public void publish(LogRecord record) {
            if (record.getMessage().equals("createFolder - before create folder if not exists.")) {
                try {
                    folder.createFolder(name);
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
        }
    };
    Logger logger = Logger.getLogger(FileUtil.class.getName());
    logger.addHandler(handler);
    logger.setLevel(Level.FINEST);
    try {
        FileUtil.createFolder(folder, name);
    } catch (IOException ioe) {
        fail("FileUtil.createFolder(FileObject, String) should try to refresh folder because other thread can create folder before.");
    } finally {
        logger.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:FileUtilTest.java

示例10: removeHandlers

import java.util.logging.Logger; //导入方法依赖的package包/类
public static void removeHandlers(Logger log) {
	if (log != null) {
		Handler[] handlers = log.getHandlers();
		for (int i = 0; i < handlers.length; i++) {
			log.removeHandler(handlers[i]);
		}
	}
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TestKit.java

示例11: replaceRootHandler

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Removes existing handlers from the root logger and installs a
 * PrintStreamLogHandler for System.out.
 */
public static void replaceRootHandler() {
    Logger global = Logger.getLogger("");
    for (Handler handler : global.getHandlers()) {
        global.removeHandler(handler);
    }
    global.addHandler(new PrintStreamLogHandler("Root Logger", System.out));
}
 
开发者ID:a-hansen,项目名称:alog,代码行数:12,代码来源:Alog.java

示例12: testConcurrentScanningBinary

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testConcurrentScanningBinary() throws Exception {
    // now testing scan of binary clusters
    ModuleList.refresh();
    final ModuleList mlref[] = new ModuleList[1];
    Logger logger = Logger.getLogger(ModuleList.class.getName());
    Level origLevel = logger.getLevel();
    ModuleListLogHandler handler = new ModuleListLogHandler();
    assertTrue("NB dest. dir exists: " + destDirF, destDirF.exists());
    try {
        logger.setLevel(Level.ALL);
        logger.addHandler(handler);

        Thread t = new Thread() {

            @Override
            public void run() {
                try {
                    mlref[0] = ModuleList.findOrCreateModuleListFromBinaries(destDirF);
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };
        long start = System.currentTimeMillis();
        t.start();
        ModuleList ml = ModuleList.findOrCreateModuleListFromBinaries(destDirF);
        t.join();
        System.out.println("Concurrent scans took " + (System.currentTimeMillis() - start) + "msec.");
        assertNull(handler.error, handler.error);   // error is non-null when duplicate scan detected
        assertNotNull("Module list for dir " + destDirF + " returned null", ml);
        assertNotNull("Module list for dir " + destDirF + " returned null", mlref[0]);
        assertTrue("No clusters scanned.", handler.scannedDirs.size() > 0);
        System.out.println("Total " + handler.scannedDirs.size() + " clusters scanned.");
        // XXX Some more possible concurrent scans could be tested, not that easy to set up,
        // e.g. ML#findOrCreateModuleListFromSuite, ...FromStandaloneModule, ...
    } finally {
        logger.removeHandler(handler);
        logger.setLevel(origLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:ModuleListTest.java

示例13: testNextEvent

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Test of nextEvent method, of class LinuxNotifier.
 *
 * @throws java.lang.Exception
 */
public void testNextEvent() throws Exception {

    if (Utilities.getOperatingSystem() != Utilities.OS_LINUX) {
        System.out.println("Skipping linux-only test: " + getName());
        return;
    }

    prepareFiles();

    final AtomicBoolean folder2refreshed = new AtomicBoolean(false);
    Logger log = Logger.getLogger(FolderObj.class.getName());

    Handler h = createHandler(folder2refreshed);
    log.addHandler(h);
    try {
        FileChangeListener l = new FileChangeAdapter();
        FileUtil.addFileChangeListener(l, folder1text1Txt);
        // This causes an IN_IGNORED native event.
        FileUtil.removeFileChangeListener(l, folder1text1Txt);
        // Native listeners may need some time.
        Thread.sleep(2000);
    } finally {
        log.removeHandler(h);
    }
    assertFalse("Folder folder2 should not be refreshed.",
            folder2refreshed.get());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:LinuxNotifier235632Test.java

示例14: removeHandlers

import java.util.logging.Logger; //导入方法依赖的package包/类
public static void removeHandlers(Logger log) {
    if (log != null) {
        Handler[] handlers = log.getHandlers();
        for (int i = 0; i < handlers.length; i++) {
            log.removeHandler(handlers[i]);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TestKit.java

示例15: testVisibilityChangeOutsideOfRoot

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Tests specific VisibilityChange but outside of the source roots.
 * Change to file (folder) outside of source roots -> no scan.
 */
public void testVisibilityChangeOutsideOfRoot() throws InterruptedException, IOException {

    assertTrue(GlobalPathRegistry.getDefault().getPaths(FOO_SOURCES).isEmpty());
    final RepositoryUpdaterTest.TestHandler handler = new RepositoryUpdaterTest.TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests"); //NOI18N
    logger.setLevel (Level.FINEST);
    logger.addHandler(handler);
    try {
        globalPathRegistry_register(FOO_SOURCES,new ClassPath[]{cp1});
        assertTrue (handler.await());
        assertEquals(0, handler.getBinaries().size());
        assertEquals(4, handler.getSources().size());
        assertEquals(
            new URI[] {
                src1file1.toURI(),
                src1file2.toURI(),
                src2file1.toURI(),
                src2file2.toURI(),
                src3file1.toURI(),
                src3file2.toURI(),
                src4file1.toURI(),
                src4file2.toURI()
            },
            MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).clearIndexedFiles());
        assertEquals(
            new URI[0],
            MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).clearRemovedFiles());
        handler.reset();
        Lookup.getDefault().lookup(MockVisibilityQuery.class).hide(outside);
        assertFalse(handler.await(RepositoryUpdaterTest.NEGATIVE_TIME));
        assertNull(handler.getBinaries());
        assertNull(handler.getSources());
    } finally {
        logger.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:VisibilityChangeTest.java


注:本文中的java.util.logging.Logger.removeHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。