本文整理汇总了Java中java.util.logging.LogManager.readConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java LogManager.readConfiguration方法的具体用法?Java LogManager.readConfiguration怎么用?Java LogManager.readConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.logging.LogManager
的用法示例。
在下文中一共展示了LogManager.readConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LoggingConfig
import java.util.logging.LogManager; //导入方法依赖的package包/类
public LoggingConfig() {
try {
// Load a properties file from class path java.util.logging.config.file
final LogManager logManager = LogManager.getLogManager();
URL configURL = getClass().getResource("/logging.properties");
if (configURL != null) {
try (InputStream is = configURL.openStream()) {
logManager.readConfiguration(is);
}
} else {
// Programmatic configuration
System.setProperty("java.util.logging.SimpleFormatter.format",
"%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n");
final ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINEST);
consoleHandler.setFormatter(new SimpleFormatter());
final Logger app = Logger.getLogger("app");
app.setLevel(Level.FINEST);
app.addHandler(consoleHandler);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: AswLogger
import java.util.logging.LogManager; //导入方法依赖的package包/类
private AswLogger() {
LogManager logManager = LogManager.getLogManager();
try {
logManager.readConfiguration(new FileInputStream(LOGGING_CONFIG_FILE));
} catch (Exception e) {
/* di solito l'eccezione si verifica perche' non trova il file logging.properties */
/* Stampa il messaggio dell'eccezione */
// System.err.println(e);
/* definisce una configurazione alternativa */
logManager.reset();
Handler handler = new ConsoleHandler();
handler.setFormatter( new TextFormatter() );
Logger.getLogger("").addHandler( handler );
}
}
示例3: setUp
import java.util.logging.LogManager; //导入方法依赖的package包/类
@Setup
public void setUp() throws IOException {
final LogManager logManager = LogManager.getLogManager();
try (final InputStream is = LoggingBenchmark.class.getResourceAsStream("/logging.properties")) {
logManager.readConfiguration(is);
}
}
示例4: accept
import java.util.logging.LogManager; //导入方法依赖的package包/类
@Override
public void accept(LogManager t) throws IOException {
t.readConfiguration();
}