Java Code Examples for java.util.logging.Logger.GLOBAL_LOGGER_NAME

The following are Jave code examples for showing how to use GLOBAL_LOGGER_NAME of the java.util.logging.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jdk8u-jdk   File: TestAppletLoggerContext.java   Source Code and License Vote up 6 votes
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);
    }
}
 
Example 2
Project: openjdk-jdk10   File: TestAppletLoggerContext.java   Source Code and License Vote up 6 votes
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);
    }
}
 
Example 3
Project: jdk8u-jdk   File: TestAppletLoggerContext.java   Source Code and License Vote up 4 votes
/**
 * 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);
        }

    }
}
 
Example 4
Project: openjdk-jdk10   File: TestAppletLoggerContext.java   Source Code and License Vote up 4 votes
/**
 * 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);
        }

    }
}