本文整理汇总了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");
});
}
示例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();
}
}
}
示例3: LogManagerImpl2
import java.util.logging.Logger; //导入方法依赖的package包/类
public LogManagerImpl2() {
globalLogger = Logger.getGlobal();
System.err.println("Global is: " + globalLogger);
}
示例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());
}
}