本文整理匯總了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());
}
}