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


Java Logger.GLOBAL_LOGGER_NAME属性代码示例

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


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

示例1: testFour

public static void testFour() {
    for (int i=0; i<3 ; i++) {
        Logger logger1 = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger1b = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        assertNotNull(logger1);
        assertNotNull(logger1b);
        assertEquals(logger1, logger1b);
        Bridge.changeContext();

        Logger logger2 = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger2b = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        assertNotNull(logger2);
        assertNotNull(logger2b);
        assertEquals(logger2, logger2b);

        assertEquals(logger1, logger2);

        Bridge.changeContext();
        Logger logger3 = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger3b = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME);
        Bridge.changeContext();
        Logger logger4 = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger4b = new Bridge.CustomAnonymousLogger(Logger.GLOBAL_LOGGER_NAME);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:TestAppletLoggerContext.java

示例2: testSix

/**
 * This test is designed to test the behavior of additional LogManager instances.
 * It must be noted that if the security manager is off, then calling
 * Bridge.changeContext() has actually no effect - which explains why we have
 * some differences between the cases security manager on & security manager
 * off.
 **/
public static void testSix() {
    for (int i=0; i<3 ; i++) {
        Bridge.desactivate();
        LogManager manager = new LogManager() {};
        Logger logger1 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger1b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
        assertNull(logger1);
        assertNull(logger1b);
        Logger global = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME);
        manager.addLogger(global);
        Logger logger2 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
        Logger logger2b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
        assertNotNull(logger2);
        assertNotNull(logger2b);
        assertEquals(logger2, global);
        assertEquals(logger2b, global);
        assertNull(manager.getLogger(""));
        assertNull(manager.getLogger(""));

        for (int j = 0; j<3; j++) {
            Bridge.changeContext();

            // this is not a supported configuration:
            // We are in an applet context with several log managers.
            // We however need to check our assumptions...

            // Applet context => root logger and global logger should also be null.

            Logger expected = (System.getSecurityManager() == null ? global : null);
            Logger logger3 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
            Logger logger3b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
            assertEquals(expected, logger3);
            assertEquals(expected, logger3b);
            Logger global2 = new Bridge.CustomLogger(Logger.GLOBAL_LOGGER_NAME);
            manager.addLogger(global2);
            Logger logger4 = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
            Logger logger4b = manager.getLogger(Logger.GLOBAL_LOGGER_NAME);
            assertNotNull(logger4);
            assertNotNull(logger4b);
            expected = (System.getSecurityManager() == null ? global : global2);;
            assertEquals(logger4,  expected);
            assertEquals(logger4b, expected);

            Logger logger5 = manager.getLogger("");
            Logger logger5b = manager.getLogger("");
            Logger expectedRoot = null;
            assertEquals(logger5, expectedRoot);
            assertEquals(logger5b, expectedRoot);
        }

    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:59,代码来源:TestAppletLoggerContext.java


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