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


Java Logger.getLevel方法代码示例

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


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

示例1: testRootCache

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testRootCache() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject root1 = FileUtil.createFolder(wd, "root1");
    final FileObject module1 = createTestFile (root1, null, "module-info.java", "module Foo {}");    //NOI18N
    final FileObject java1 = createTestFile (root1, "org/nb/test", "Test.java", "package org.nb.test;\nclass Test {}");    //NOI18N
    final FileObject root2 = FileUtil.createFolder(wd, "root2");
    final FileObject module2 = createTestFile (root2, null, "module-info.java", "module Boo {}");    //NOI18N
    final FileObject java2 = createTestFile (root2, "org/nb/test", "Test2.java", "package org.nb.test;\nclass Test2 {}");    //NOI18N
    final Logger l = Logger.getLogger(DefaultSourceLevelQueryImpl.class.getName());
    final Level origLogLevel = l.getLevel();
    final H h = new H();
    l.setLevel(Level.FINE);
    l.addHandler(h);
    try {
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        List<? extends FileObject> roots = h.getRoots();
        assertEquals(1, roots.size());
        assertEquals(root1, roots.get(0));
        h.reset();
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        roots = h.getRoots();
        assertEquals(0, roots.size());
        h.reset();
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java2));
        roots = h.getRoots();
        assertEquals(1, roots.size());
        assertEquals(root2, roots.get(0));
    } finally {
        l.removeHandler(h);
        l.setLevel(origLogLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:DefaultSourceLevelQueryImplTest.java

示例2: testIsModuleCache

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testIsModuleCache() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject root1 = FileUtil.createFolder(wd, "root1");
    final FileObject module1 = createTestFile (root1, null, "module-info.java", "module Foo {}");    //NOI18N
    final FileObject java1 = createTestFile (root1, "org/nb/test", "Test.java", "package org.nb.test;\nclass Test {}");    //NOI18N
    final FileObject root2 = FileUtil.createFolder(wd, "root2");
    final FileObject java2 = createTestFile (root2, "org/nb/test", "Test2.java", "package org.nb.test;\nclass Test2 {}");    //NOI18N
    final Logger l = Logger.getLogger(DefaultSourceLevelQueryImpl.class.getName());
    final Level origLogLevel = l.getLevel();
    final H h = new H();
    l.setLevel(Level.FINE);
    l.addHandler(h);
    try {
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        List<? extends Boolean> isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.TRUE, isMods.get(0));
        h.reset();
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        isMods = h.getIsModules();
        assertEquals(0, isMods.size());
        h.reset();
        assertEquals(
                JavaPlatform.getDefault().getSpecification().getVersion().toString(),
                SourceLevelQuery.getSourceLevel(java2));
        isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.FALSE, isMods.get(0));
    } finally {
        l.removeHandler(h);
        l.setLevel(origLogLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:DefaultSourceLevelQueryImplTest.java

示例3: testIsModuleCache_ModuleInfoDeleted

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testIsModuleCache_ModuleInfoDeleted() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject root1 = FileUtil.createFolder(wd, "root1");
    FileObject module1 = createTestFile (root1, null, "module-info.java", "module Foo {}");    //NOI18N
    final FileObject java1 = createTestFile (root1, "org/nb/test", "Test.java", "package org.nb.test;\nclass Test {}");    //NOI18N
    final Logger l = Logger.getLogger(DefaultSourceLevelQueryImpl.class.getName());
    final Level origLogLevel = l.getLevel();
    final H h = new H();
    l.setLevel(Level.FINE);
    l.addHandler(h);
    try {
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        List<? extends Boolean> isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.TRUE, isMods.get(0));
        h.reset();
        module1.delete();
        assertEquals(
                JavaPlatform.getDefault().getSpecification().getVersion().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.FALSE, isMods.get(0));
        h.reset();
        assertEquals(
                JavaPlatform.getDefault().getSpecification().getVersion().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        isMods = h.getIsModules();
        assertEquals(0, isMods.size());
    } finally {
        l.removeHandler(h);
        l.setLevel(origLogLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:DefaultSourceLevelQueryImplTest.java

示例4: testIsModuleCache_ModuleInfoCreated

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testIsModuleCache_ModuleInfoCreated() throws IOException {
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    final FileObject root1 = FileUtil.createFolder(wd, "root1");
    final FileObject java1 = createTestFile (root1, "org/nb/test", "Test.java", "package org.nb.test;\nclass Test {}");    //NOI18N
    final Logger l = Logger.getLogger(DefaultSourceLevelQueryImpl.class.getName());
    final Level origLogLevel = l.getLevel();
    final H h = new H();
    l.setLevel(Level.FINE);
    l.addHandler(h);
    try {
        assertEquals(
                JavaPlatform.getDefault().getSpecification().getVersion().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        List<? extends Boolean> isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.FALSE, isMods.get(0));
        h.reset();
        FileObject module1 = createTestFile (root1, null, "module-info.java", "module Foo {}");    //NOI18N
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        isMods = h.getIsModules();
        assertEquals(1, isMods.size());
        assertEquals(Boolean.TRUE, isMods.get(0));
        h.reset();
        assertEquals(
                expectedSourceLevel().toString(),
                SourceLevelQuery.getSourceLevel(java1));
        isMods = h.getIsModules();
        assertEquals(0, isMods.size());
    } finally {
        l.removeHandler(h);
        l.setLevel(origLogLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:DefaultSourceLevelQueryImplTest.java

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

示例6: testLRUCaching

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testLRUCaching() 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<JavaPlatform> plts = h.getLRU();
        assertEquals(1, plts.size());
        assertEquals(j9, plts.get(0));
        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.getLRU();
        assertEquals(0, plts.size());
    } finally {
        log.removeHandler(h);
        log.setLevel(origLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DefaultClassPathProviderTest.java

示例7: getEffectiveLevel

import java.util.logging.Logger; //导入方法依赖的package包/类
public static Level getEffectiveLevel(Logger logger) {
    if(logger.getLevel() != null) {
        return logger.getLevel();
    }

    if(logger.getParent() != null) {
        return getEffectiveLevel(logger.getParent());
    }

    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:Logging.java

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

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

import java.util.logging.Logger; //导入方法依赖的package包/类
static TraceHandler register() {
    final Logger l = Logger.getLogger(ModuleNames.class.getName());
    final Level origLevel = l.getLevel();
    final TraceHandler th = new TraceHandler(l, origLevel);
    l.setLevel(Level.FINE);
    l.addHandler(th);
    return th;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ModuleNamesTest.java

示例11: levelOf

import java.util.logging.Logger; //导入方法依赖的package包/类
private Level levelOf(Logger log) {
    Level lvl = log.getLevel();
    if (lvl != null) {
        return lvl;
    } else {
        Logger par = log.getParent();
        if (par != null) {
            return levelOf(par);
        } else {
            return Level.INFO;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:EmbedderFactory.java

示例12: setupLogging

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void setupLogging() {
    // Set logging level to at least WARNING for apache so that it doesn't log auth cookies.
    try {
        Logger apacheLogger = Logger.getLogger("org.apache");
        if (apacheLogger.getLevel() == null
                || apacheLogger.getLevel().intValue() < Level.WARNING.intValue()) {
            apacheLogger.setLevel(Level.WARNING);
        }
    } catch (Exception e) {
        LOG.log(Level.WARNING, "Error setting logger level on apache logger!", e);
    }
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:13,代码来源:ConfigurationHelper.java

示例13: testEncodingCaching

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testEncodingCaching() throws Exception {
    final Logger log = Logger.getLogger(HtmlDataObject.class.getName());
    class TestHandler extends Handler {
        private final Pattern pattern = Pattern.compile("^HtmlDataObject.getFileEncoding (non)?cached .*$");   //NOI18N
        Boolean cached;
        @Override
        public void publish(LogRecord record) {
            final String message = record.getMessage();
            final Matcher matcher = pattern.matcher(message);
            if (matcher.matches()) {
                cached = matcher.group(1) == null ? Boolean.TRUE : Boolean.FALSE;
            }
        }
        @Override
        public void flush() {
        }
        @Override
        public void close() throws SecurityException {
        }
    }
    final TestHandler handler = new TestHandler();
    log.addHandler(handler);
    final Level origLevel = log.getLevel();
    log.setLevel(Level.FINEST);
    try {
        FileObject data = FileUtil.createData (FileUtil.toFileObject(getWorkDir()), "UTF8.html"); //NOI18N
        copy("UTF8.html",data); //NOI18N
        handler.cached = null;
        read(data);
        assertFalse("Encoding should be calculated",handler.cached);    //NOI18N
        handler.cached = null;
        read(data);
        assertTrue("Encoding should be cached",handler.cached);        //NOI18N
        //Modify file
        copy("UTF8.html",data); //NOI18N
        handler.cached = null;
        read(data);
        assertFalse("Encoding should be calculated",handler.cached);    //NOI18N
        handler.cached = null;
        read(data);
        assertTrue("Encoding should be cached",handler.cached);        //NOI18N
    } finally {
        log.setLevel(origLevel);
        log.removeHandler(handler);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:EncodingTest.java

示例14: testRootCache

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testRootCache() {
    Lookup.getDefault().lookup(CPP.class)
            .add(
                    root1,
                    ClassPath.SOURCE,
                    ClassPathSupport.createClassPath(root1))
            .add(
                    root2,
                    ClassPath.SOURCE,
                    ClassPathSupport.createClassPath(root2));
    final Logger l = Logger.getLogger(ModuleOraculum.class.getName());
    final Level origLogLevel = l.getLevel();
    final H h = new H();
    l.setLevel(Level.FINE);
    l.addHandler(h);
    try {
        final ClasspathInfo cpInfo = new ClasspathInfo.Builder(ClassPath.EMPTY).build();
        final JavacParser parser = new JavacParser(Collections.emptyList(), true);
        JavacTaskImpl impl = JavacParser.createJavacTask(
                javaFile1,
                null,
                cpInfo,
                parser,
                null,
                false);
        assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
        List<? extends FileObject> roots = h.getRoots();
        assertEquals(1, roots.size());
        assertEquals(root1, roots.get(0));
        h.reset();
        impl = JavacParser.createJavacTask(
                javaFile1,
                null,
                cpInfo,
                parser,
                null,
                false);
        assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
        roots = h.getRoots();
        assertEquals(0, roots.size());
        impl = JavacParser.createJavacTask(
                javaFile2,
                null,
                cpInfo,
                parser,
                null,
                false);
        assertEquals("Next", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
        roots = h.getRoots();
        assertEquals(1, roots.size());
        assertEquals(root2, roots.get(0));
    } finally {
        l.removeHandler(h);
        l.setLevel(origLogLevel);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:57,代码来源:ModuleOraculumTest.java

示例15: disableLogging

import java.util.logging.Logger; //导入方法依赖的package包/类
@BeforeClass
public static void disableLogging() {
    Logger pdfboxLogger = Logger.getLogger("org.apache.pdfbox");
    defaultLogLevel = pdfboxLogger.getLevel();
    pdfboxLogger.setLevel(Level.OFF);
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:7,代码来源:TestTableDetection.java


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