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


Java Logger.getGlobal方法代码示例

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


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

示例1: main

import java.util.logging.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
    Logger log = Logger.getGlobal();
    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.ALL);
    log.addHandler(handler);
    log.setLevel(Level.ALL);
    JFrame fra = new JFrame("bitbox");
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    BaseConverter baseConverter = new BaseConverter();
    BitCombiner bitCombiner = new BitCombiner();
    BitPainter bitPainter = new BitPainter();
    SwingUtilities.invokeLater(() -> {
        fra.setSize(new Dimension(500, screenSize.height));
        fra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        fra.setLayout(new GridLayout(GRID_SIZE, GRID_SIZE));
        fra.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
        fra.add(baseConverter);
        fra.add(bitCombiner);
        fra.add(bitPainter);
        fra.setVisible(true);
        log.fine("Created GUI");
    });
}
 
开发者ID:fusiled,项目名称:bitbox,代码行数:24,代码来源:Main.java

示例2: test

import java.util.logging.Logger; //导入方法依赖的package包/类
@Test
void test() {
	Logger l = Logger.getGlobal();
	l.addHandler(new LoggingHandler());
	l.info("This is just an INFO.");
	l.warning("This is a WARNING!");
	l.severe("HOLY SH*T GET DOWN!");
	for (int i = 0; i != 10; i++) {
		l.info("This is just an INFO.");
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			fail();
		}
	}
}
 
开发者ID:Electro-Light,项目名称:ElectroLight-Intrusion-Detection,代码行数:17,代码来源:LoggerTest.java

示例3: LogManagerImpl2

import java.util.logging.Logger; //导入方法依赖的package包/类
public LogManagerImpl2() {
    globalLogger = Logger.getGlobal();
    System.err.println("Global is: " + globalLogger);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:LogManagerImpl2.java

示例4: testLoggableLevels

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

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

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


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