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


Java Logger.setLevel方法代码示例

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


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

示例1: testPartiallyConstructedManager

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Catches a bug where when constructing a service manager failed, later interactions with the
 * service could cause IllegalStateExceptions inside the partially constructed ServiceManager.
 * This ISE wouldn't actually bubble up but would get logged by ExecutionQueue.  This obfuscated
 * the original error (which was not constructing ServiceManager correctly).
 */
public void testPartiallyConstructedManager() {
  Logger logger = Logger.getLogger("global");
  logger.setLevel(Level.FINEST);
  TestLogHandler logHandler = new TestLogHandler();
  logger.addHandler(logHandler);
  NoOpService service = new NoOpService();
  service.startAsync();
  try {
    new ServiceManager(Arrays.asList(service));
    fail();
  } catch (IllegalArgumentException expected) {}
  service.stopAsync();
  // Nothing was logged!
  assertEquals(0, logHandler.getStoredLogRecords().size());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:22,代码来源:ServiceManagerTest.java

示例2: 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

示例3: testChangesNotVisibleAfterRollBack

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testChangesNotVisibleAfterRollBack() 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);

        MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).setCancelScanning(true);

        globalPathRegistry_register(FOO_SOURCES,new ClassPath[]{cp1});
        assertTrue (handler.await());
        assertEquals(0, handler.getBinaries().size());
        assertEquals(1, handler.getSources().size());
        assertEquals(this.src1.toURL(), handler.getSources().get(0));
        assertFalse(MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).isSuccess());
        QuerySupport qs = QuerySupport.forRoots(FooIndexerFactory.NAME, FooIndexerFactory.VERSION, src1);
        final Collection<? extends IndexResult> res = qs.query("_sn", "", QuerySupport.Kind.PREFIX, (String[]) null);   //NOI18N
        assertEquals(0, res.size());
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:IndexingSupportACIDTest.java

示例4: MockConstrainedIndexer

import java.util.logging.Logger; //导入方法依赖的package包/类
MockConstrainedIndexer() {
    h = new Handler() {
        @Override
        public void publish(LogRecord record) {
            if (record.getMessage().equals("RootsWork-finished")) {
                sem.release();
            }
        }
        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
        }
    };
    final Logger log = Logger.getLogger(RepositoryUpdater.class.getName() + ".tests"); //NOI18N
    log.setLevel(Level.FINEST);
    log.addHandler(h);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ConstrainedBinaryIndexerTest.java

示例5: 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

示例6: main

import java.util.logging.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
    System.setSecurityManager(new SecurityManager());
    Logger anonymous = Logger.getAnonymousLogger();

    final TestHandler handler = new TestHandler();
    final TestFilter filter = new TestFilter();
    final ResourceBundle bundle = ResourceBundle.getBundle(TestBundle.class.getName());
    anonymous.setLevel(Level.FINEST);
    anonymous.addHandler(handler);
    anonymous.setFilter(filter);
    anonymous.setUseParentHandlers(true);
    anonymous.setResourceBundle(bundle);

    if (anonymous.getLevel() != Level.FINEST) {
        throw new RuntimeException("Unexpected level: " + anonymous.getLevel());
    } else {
        System.out.println("Got expected level: " + anonymous.getLevel());
    }
    if (!Arrays.asList(anonymous.getHandlers()).contains(handler)) {
        throw new RuntimeException("Expected handler not found in: "
                + Arrays.asList(anonymous.getHandlers()));
    } else {
        System.out.println("Got expected handler in: " + Arrays.asList(anonymous.getHandlers()));
    }
    if (anonymous.getFilter() != filter) {
        throw new RuntimeException("Unexpected filter: " + anonymous.getFilter());
    } else {
        System.out.println("Got expected filter: " + anonymous.getFilter());
    }
    if (!anonymous.getUseParentHandlers()) {
        throw new RuntimeException("Unexpected flag: " + anonymous.getUseParentHandlers());
    } else {
        System.out.println("Got expected flag: " + anonymous.getUseParentHandlers());
    }
    if (anonymous.getResourceBundle() != bundle) {
        throw new RuntimeException("Unexpected bundle: " + anonymous.getResourceBundle());
    } else {
        System.out.println("Got expected bundle: " + anonymous.getResourceBundle());
    }
    try {
        anonymous.setParent(Logger.getLogger("foo.bar"));
        throw new RuntimeException("Expected SecurityException not raised!");
    } catch (SecurityException x) {
        System.out.println("Got expected exception: " + x);
    }
    if (anonymous.getParent() != Logger.getLogger("")) {
        throw new RuntimeException("Unexpected parent: " + anonymous.getParent());
    } else {
        System.out.println("Got expected parent: " + anonymous.getParent());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:TestAnonymousLogger.java

示例7: setSilent

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Controls if the loggers will be silenced or not.
 * @param silent    <code>true</code> sets the log level to WARN for the
 *                  loggers that log information on Tomcat start up. This
 *                  prevents the usual startup information being logged.
 *                  <code>false</code> sets the log level to the default
 *                  level of INFO.
 */
public void setSilent(boolean silent) {
    this.silent = silent;
    for (String s : silences) {
        Logger logger = Logger.getLogger(s);
        pinnedLoggers.put(s, logger);
        if (silent) {
            logger.setLevel(Level.WARNING);
        } else {
            logger.setLevel(Level.INFO);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:Tomcat.java

示例8: testJavaPlatformCaching

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testJavaPlatformCaching() throws IOException {
    FileObject artefact = getSourceFile (FILE_IN_PACKAGE);
    Lookup.getDefault().lookup(MockSLQ.class).register(this.srcRoot, new SpecificationVersion("9"));  //NOI18N
    assertEquals("9", SourceLevelQuery.getSourceLevel(artefact)); //NOI18N
    ClassPathProvider cpp = new DefaultClassPathProvider ();
    final Logger log = Logger.getLogger(DefaultClassPathProvider.class.getName());
    final H h = new H();
    final Level origLevel = log.getLevel();
    log.setLevel(Level.FINE);
    log.addHandler(h);
    try {
        ClassPath cp = cpp.findClassPath(artefact, JavaClassPathConstants.MODULE_BOOT_PATH);
        assertEquals ("DefaultClassPathProvider returned invalid classpath for MODULE_BOOT_PATH with source level 9",
                j9.getBootstrapLibraries(),
                cp);
        List<Optional<JavaPlatform>> plts = h.getCachedPlatforms();
        assertEquals(1, plts.size());
        assertEquals(j9, plts.get(0).get());
        h.reset();
        artefact = getSourceFile (FILE_IN_PACKAGE);
        cp = cpp.findClassPath(artefact, JavaClassPathConstants.MODULE_BOOT_PATH);
        assertEquals ("DefaultClassPathProvider returned invalid classpath for MODULE_BOOT_PATH with source level 9",
                j9.getBootstrapLibraries(),
                cp);
        plts = h.getCachedPlatforms();
        assertEquals(0, plts.size());
    } finally {
        log.removeHandler(h);
        log.setLevel(origLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DefaultClassPathProviderTest.java

示例9: testDeletedFileDoesNotReturnInputStream

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testDeletedFileDoesNotReturnInputStream() throws Exception {
    final FileObject testFo = FileUtil.createData(root,"testfile.data");
    final File testFile = FileUtil.toFile(testFo);
    final Logger LOGGER = Logger.getLogger(FileObj.class.getName());
    final Handler handler = new Handler() {
        @Override
        public void publish(LogRecord record) {
            if ("FileObj.getInputStream_after_is_valid".equals(record.getMessage())) {
                testFile.delete();
            }
        }
        @Override
        public void flush() {
        }
        @Override
        public void close() throws SecurityException {
        }
    };
    final Level originalLevel = LOGGER.getLevel();
    LOGGER.setLevel(Level.FINEST);
    try {
        LOGGER.addHandler(handler);
        try {
            testFo.getInputStream();
            assertTrue("Exception not thrown by deleted file getInputStream()", false);
        } catch (FileNotFoundException e) {
            //pass - expected exception
        } finally {
            LOGGER.removeHandler(handler);
        }
    } finally {
        LOGGER.setLevel(originalLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:BaseFileObjectTestHid.java

示例10: setUp

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    branding = NbBundle.getBranding();
    locale = Locale.getDefault();
    
    clearWorkDir();
    
    install = new File(getWorkDir(), "install");
    platform = new File(install, "platform");
    ide = new File(install, "ide");
    userdir = new File(getWorkDir(), "tmp");
    cache = new File(install, "cache");
    
    System.setProperty("netbeans.home", platform.getPath());
    System.setProperty("netbeans.dirs", ide.getPath());
    System.setProperty("netbeans.user", userdir.getPath());
    
    createModule("org.openide.awt", platform, 50000L);
    createModule("org.openide.nodes", platform, 60000L);
    createModule("org.netbeans.api.languages", ide, 90000L);
    createModule("org.netbeans.modules.logmanagement", userdir, 10000L);
    
    Thread.sleep(100);
    
    createPopulateZip();

    Logger l = Logger.getLogger("org");
    l.setLevel(Level.OFF);
    l.setUseParentHandlers(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:StampsDifferentPopulateTest.java

示例11: doRun

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void doRun ( URI u, final Object payloadObject, String username, String password ) {
    ConnectionProvider instance = null;
    ConnectionProviderContextImpl context = null;
    ConnectionHandler ch = null;
    Channel c = null;
    VersionedConnection vc = null;
    try {
        Logger logger = LogManager.getLogManager().getLogger("");
        logger.addHandler(new ConsoleLogHandler());
        logger.setLevel(Level.INFO);
        OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
        context = new ConnectionProviderContextImpl(options, "endpoint");
        instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
        String host = u.getHost();
        int port = u.getPort() > 0 ? u.getPort() : 9990;
        SocketAddress destination = new InetSocketAddress(host, port);
        ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
        ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
        c = getChannel(context, ch, options);
        System.err.println("Connected");
        vc = makeVersionedConnection(c);
        MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
        doExploit(payloadObject, mbc);
        System.err.println("DONE");
    }
    catch ( Throwable e ) {
        e.printStackTrace(System.err);
    }
    finally {
        cleanup(instance, context, ch, c, vc);
    }
}
 
开发者ID:RickGray,项目名称:ysoserial-plus,代码行数:33,代码来源:JBoss.java

示例12: 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

示例13: initServer

import java.util.logging.Logger; //导入方法依赖的package包/类
static void initServer() throws Exception {

        Logger logger = Logger.getLogger("com.sun.net.httpserver");
        ConsoleHandler ch = new ConsoleHandler();
        logger.setLevel(Level.SEVERE);
        ch.setLevel(Level.SEVERE);
        logger.addHandler(ch);

        String root = System.getProperty ("test.src")+ "/docs";
        InetSocketAddress addr = new InetSocketAddress (0);
        s1 = HttpServer.create (addr, 0);
        if (s1 instanceof HttpsServer) {
            throw new RuntimeException ("should not be httpsserver");
        }
        s2 = HttpsServer.create (addr, 0);
        HttpHandler h = new FileServerHandler(root);

        HttpContext c1 = s1.createContext("/files", h);
        HttpContext c2 = s2.createContext("/files", h);
        HttpContext c3 = s1.createContext("/echo", new EchoHandler());
        redirectHandler = new RedirectHandler("/redirect");
        redirectHandlerSecure = new RedirectHandler("/redirect");
        HttpContext c4 = s1.createContext("/redirect", redirectHandler);
        HttpContext c41 = s2.createContext("/redirect", redirectHandlerSecure);
        HttpContext c5 = s2.createContext("/echo", new EchoHandler());
        HttpContext c6 = s1.createContext("/keepalive", new KeepAliveHandler());
        redirectErrorHandler = new RedirectErrorHandler("/redirecterror");
        redirectErrorHandlerSecure = new RedirectErrorHandler("/redirecterror");
        HttpContext c7 = s1.createContext("/redirecterror", redirectErrorHandler);
        HttpContext c71 = s2.createContext("/redirecterror", redirectErrorHandlerSecure);
        delayHandler = new DelayHandler();
        HttpContext c8 = s1.createContext("/delay", delayHandler);
        HttpContext c81 = s2.createContext("/delay", delayHandler);

        executor = Executors.newCachedThreadPool();
        s1.setExecutor(executor);
        s2.setExecutor(executor);
        ctx = new SimpleSSLContext().get();
        sslparams = ctx.getSupportedSSLParameters();
        s2.setHttpsConfigurator(new Configurator(ctx));
        s1.start();
        s2.start();

        port = s1.getAddress().getPort();
        System.out.println("HTTP server port = " + port);
        httpsport = s2.getAddress().getPort();
        System.out.println("HTTPS server port = " + httpsport);
        httproot = "http://127.0.0.1:" + port + "/";
        httpsroot = "https://127.0.0.1:" + httpsport + "/";

        proxy = new ProxyServer(0, false);
        proxyPort = proxy.getPort();
        System.out.println("Proxy port = " + proxyPort);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:55,代码来源:SmokeTest.java

示例14: testDeletedFile

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testDeletedFile() throws Exception {
    CompileTuple ct = files.iterator().next();
    final FileObject fo = URLMapper.findFileObject(ct.indexable.getURL());        
    fo.delete();
    
    JavaIndexerWorker.TEST_DO_PREFETCH = true;
    final LogHandler handler = new LogHandler();
    handler.expect("Using concurrent iterator, {0} workers");    //NOI18N
    final Logger log = Logger.getLogger(JavaIndexerWorker.class.getName());
    log.setLevel(Level.FINE);
    log.addHandler(handler);
    try {
        SourcePrefetcher pf = SourcePrefetcher.create(files, SuspendSupport.NOP);
        assertTrue(handler.isFound());
        final Deque<CompileTuple> got = new ArrayDeque<CompileTuple>(FILE_COUNT);
        while (pf.hasNext()) {
            ct = pf.next();
            try {
                if (ct != null) {
                    assertNotNull(getCache(ct.jfo));
                    got.offer(ct);
                }
            } finally {
                pf.remove();
            }
            if (ct != null) {
                assertNull(getCache(ct.jfo));
            }
        }
        final List<CompileTuple> allButFirst = new LinkedList<CompileTuple>(files);
        allButFirst.remove(0);
        assertCollectionsEqual(allButFirst,got);
    } finally {
        log.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:SourcePrefetcherTest.java

示例15: testFLWOnMultipleRootsWithIntermediateDelWorkFollowedByFLWNotAbsorbed

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Tests that consequent file list works on different roots with intermediate delete work on first root
 * are not collapsed.
 * Runs special work at start which in execution schedules FLW(src1), DEL(src1), FLW(src2), FLW(src1) -> 3 FLWs should
 * be executed.
 */
public void testFLWOnMultipleRootsWithIntermediateDelWorkFollowedByFLWNotAbsorbed() 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(2, handler.getSources().size());

        handler.reset(RepositoryUpdaterTest.TestHandler.Type.FILELIST);
        MimeLookup.getLookup(MimePath.get(FOO_MIME)).
                lookup(FooIndexerFactory.class).
                reset();
        RepositoryUpdater.getDefault().runAsWork(
            new Runnable() {
               @Override
               public void run() {
                   //First schedule of refresh for src1
                   IndexingManager.getDefault().refreshIndex(
                      src1.toURL(),
                      Collections.<URL>emptyList(),
                      false);
                   //Second schedulte some delete in src2
                   RepositoryUpdater.getDefault().addDeleteJob(
                      src1.toURL(),
                      Collections.<String>emptySet(),
                      LogContext.create(LogContext.EventType.PATH, "Test"));    //NOI18N
                   //Third schedule of refresh for src1
                   IndexingManager.getDefault().refreshIndex(
                      src2.toURL(),
                      Collections.<URL>emptyList(),
                      false);
                   //Fourth schedule of refresh for src1
                   IndexingManager.getDefault().refreshIndex(
                      src1.toURL(),
                      Collections.<URL>emptyList(),
                      false);
               }
            });
        assertTrue (handler.await());
        assertTrue (awaitRUSilence());
        assertEquals(3, MimeLookup.getLookup(MimePath.get(FOO_MIME)).
                        lookup(FooIndexerFactory.class).
                        getIndexingCount());
    } finally {
        logger.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:59,代码来源:FileListWorkOrderingTest.java


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