java.util.logging.Logger.info()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(551)

本文整理了Java中java.util.logging.Logger.info()方法的一些代码示例,展示了Logger.info()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.info()方法的具体详情如下:
包路径:java.util.logging.Logger
类名称:Logger
方法名:info

Logger.info介绍

[英]Log an INFO message.

If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.
[中]记录一条信息消息。
如果记录器当前已启用信息消息级别,则给定消息将转发到所有已注册的输出处理程序对象。

代码示例

代码示例来源:origin: square/okhttp

  1. @Override protected void execute() {
  2. try {
  3. processConnection();
  4. } catch (IOException e) {
  5. logger.info(
  6. MockWebServer.this + " connection from " + raw.getInetAddress() + " failed: " + e);
  7. } catch (Exception e) {
  8. logger.log(Level.SEVERE,
  9. MockWebServer.this + " connection from " + raw.getInetAddress() + " crashed", e);
  10. }
  11. }

代码示例来源:origin: stackoverflow.com

  1. import java.util.logging.Logger;
  2. public class Main {
  3. private static Logger LOGGER = Logger.getLogger("InfoLogging");
  4. public static void main(String[] args) {
  5. LOGGER.info("Logging an INFO-level message");
  6. }
  7. }

代码示例来源:origin: iBotPeaches/Apktool

  1. @Override
  2. public void run() {
  3. try {
  4. BufferedReader br = new BufferedReader(new InputStreamReader(mIn));
  5. String line;
  6. while ((line = br.readLine()) != null) {
  7. if (mType.equals("OUTPUT")) {
  8. LOGGER.info(line);
  9. } else {
  10. LOGGER.warning(line);
  11. }
  12. }
  13. } catch (IOException ex) {
  14. ex.printStackTrace();
  15. }
  16. }

代码示例来源:origin: gocd/gocd

  1. arguments.add(defaultJava);
  2. arguments.add("-Xms" + startMem + "m");
  3. arguments.add("-Xmx" + maxMem + "m");
  4. arguments.add("-XX:MaxMetaspaceSize=" + maxPerm + "m");
  5. if (dbDebugMode) {
  6. arguments.add("-jar");
  7. arguments.add(new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getAbsolutePath());
  8. LOG.info("Running server as: " + arguments);
  9. String[] args = arguments.toArray(new String[arguments.size()]);

代码示例来源:origin: hankcs/HanLP

  1. logger.info("自定义词典开始加载:" + mainPath);
  2. if (loadDat(mainPath, dat)) return true;
  3. TreeMap<String, CoreDictionary.Attribute> map = new TreeMap<String, CoreDictionary.Attribute>();
  4. logger.info("以默认词性[" + defaultNature + "]加载自定义词典" + p + "中……");
  5. boolean success = load(p, defaultNature, map, customNatureCollector);
  6. if (!success) logger.warning("失败:" + p);
  7. logger.warning("没有加载到任何词条");
  8. logger.info("正在构建DoubleArrayTrie……");
  9. dat.build(map);
  10. if (isCache)
  11. logger.info("正在缓存词典为dat文件……");
  12. attributeList.add(entry.getValue());
  13. out.writeInt(attributeList.size());
  14. for (CoreDictionary.Attribute attribute : attributeList)
  15. logger.warning("自定义词典" + mainPath + "缓存失败!\n" + TextUtility.exceptionToString(e));

代码示例来源:origin: chewiebug/GCViewer

  1. public GCModel read() throws IOException {
  2. if (getLogger().isLoggable(Level.INFO)) getLogger().info("Reading Sun 1.3.1 format...");
  3. try {
  4. count = 0;
  5. char c = (char) i;
  6. if (c == '[') {
  7. if (line != null) lineStack.add(line); // push
  8. line = new StringBuilder(64);
  9. if (getLogger().isLoggable(Level.WARNING)) getLogger().log(Level.WARNING, e.getMessage(), e);
  10. e.printStackTrace();
  11. line = lineStack.remove(lineStack.size() - 1); // pop
  12. if (getLogger().isLoggable(Level.INFO)) getLogger().info("Done reading.");

代码示例来源:origin: stanfordnlp/CoreNLP

  1. public List<String> annotateMulticlass(List<Datum<String, String>> testDatums) {
  2. List<String> predictedLabels = new ArrayList<>();
  3. for (Datum<String, String> testDatum: testDatums) {
  4. String label = classOf(testDatum, null);
  5. Counter<String> probs = probabilityOf(testDatum);
  6. double prob = probs.getCount(label);
  7. StringWriter sw = new StringWriter();
  8. PrintWriter pw = new PrintWriter(sw);
  9. if (logger.isLoggable(Level.FINE)) {
  10. justificationOf(testDatum, pw, label);
  11. }
  12. logger.fine("JUSTIFICATION for label GOLD:" + testDatum.label() + " SYS:" + label + " (prob:" + prob + "):\n"
  13. + sw.toString() + "\nJustification done.");
  14. predictedLabels.add(label);
  15. if(! testDatum.label().equals(label)){
  16. logger.info("Classification: found different type " + label + " for relation: " + testDatum);
  17. } else{
  18. logger.info("Classification: found similar type " + label + " for relation: " + testDatum);
  19. }
  20. }
  21. return predictedLabels;
  22. }

代码示例来源:origin: jersey/jersey

  1. private static List<JavaFile> getJavaFiles(File configFile) throws Exception {
  2. final List<JavaFile> javaFiles = new LinkedList<>();
  3. try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), "UTF-8"))) {
  4. while (r.ready()) {
  5. final String className = r.readLine();
  6. if (!className.startsWith("#")) {
  7. javaFiles.add(new JavaFile(className, SRC_MAIN_JAVA));
  8. LOGGER.info(String.format(" + included class %s.\n", className));
  9. } else {
  10. LOGGER.info(String.format(" - ignored class %s\n", className.substring(1)));
  11. }
  12. }
  13. }
  14. return javaFiles;
  15. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. cmd.add("-props");
  2. cmd.add(propsFile);
  3. ProcessBuilder pb = new ProcessBuilder(cmd);
  4. pbEnv.putAll(curEnv);
  5. logger.info("Running distributed coref:" + StringUtils.join(pb.command(), " "));
  6. StringWriter outSos = new StringWriter();
  7. StringWriter errSos = new StringWriter();
  8. String outStr = outSos.toString();
  9. String errStr = errSos.toString();
  10. logger.info("Finished distributed coref: " + runDistCmd + ", props=" + propsFile);
  11. logger.info("Output: " + outStr);
  12. if (errStr.length() > 0) {
  13. logger.info("Error: " + errStr);

代码示例来源:origin: jenkinsci/jenkins

  1. File classes = new File(expandDir, "WEB-INF/classes");
  2. if (classes.exists()) { // should not normally happen, due to createClassJarFromWebInfClasses
  3. LOGGER.log(Level.WARNING, "Deprecated unpacked classes directory found in {0}", classes);
  4. paths.add(classes);
  5. LOGGER.info("Plugin " + archive.getName() + " is disabled");
  6. PluginWrapper.Dependency d = new PluginWrapper.Dependency(s);
  7. if (d.optional) {
  8. optionalDependencies.add(d);
  9. } else {
  10. dependencies.add(d);

代码示例来源:origin: hankcs/HanLP

  1. logger.warning("读取" + path + "失败" + e);
  2. return false;
  3. for (Map.Entry<String, V> entry : entrySet)
  4. keyList.add(entry.getKey());
  5. valueList.add(entry.getValue());
  6. logger.warning("trie建立失败");
  7. return false;
  8. logger.info(path + "加载成功,耗时" + (System.currentTimeMillis() - start) + "ms");
  9. saveDat(path + BIN_EXT, valueList);
  10. return true;

代码示例来源:origin: geoserver/geoserver

  1. if (!(appender instanceof ConsoleAppender || appender instanceof FileAppender)) {
  2. appenders.add(appender);
  3. logFileName =
  4. new File(loader.getBaseDirectory(), logFileName).getAbsolutePath();
  5. LoggingInitializer.LOGGER.fine(
  6. "Non-absolute pathname detected for logfile. Setting logfile relative to data dir.");
  7. LoggingInitializer.LOGGER.fine("Logging output to file '" + logFileName + "'");
  8. } else if (gslf != null) {
  9. LoggingInitializer.LOGGER.warning(
  10. "'log4j.appender.geoserverlogfile' appender is defined, but isn't a FileAppender. GeoServer won't control the file-based logging.");
  11. } else {
  12. LoggingInitializer.LOGGER.warning(
  13. "'log4j.appender.geoserverlogfile' appender isn't defined. GeoServer won't control the file-based logging.");
  14. LoggingInitializer.LOGGER.info(
  15. "Suppressing StdOut logging. If you want to see GeoServer logs, be sure to look in '"
  16. + logFileName
  17. LogManager.getRootLogger().addAppender(appender);
  18. LoggingInitializer.LOGGER.fine(
  19. "FINISHED CONFIGURING GEOSERVER LOGGING -------------------------");

代码示例来源:origin: sohutv/cachecloud

  1. boolean sentinelAvailable = false;
  2. log.info("Trying to find master from available Sentinels...");
  3. log.fine("Connecting to Sentinel " + hap);
  4. if (masterAddr == null || masterAddr.size() != 2) {
  5. log.warning("Can not get master addr, master name: " + masterName + ". Sentinel: " + hap
  6. + ".");
  7. continue;
  8. log.fine("Found Redis master at " + master);
  9. break;
  10. } catch (JedisException e) {
  11. log.warning("Cannot get master address from sentinel running @ " + hap + ". Reason: " + e
  12. + ". Trying next one.");
  13. } finally {
  14. log.info("Redis master running at " + master + ", starting Sentinel listeners...");

代码示例来源:origin: stanfordnlp/CoreNLP

  1. logger.fine(timeStamp);
  2. logger.fine(props.toString());
  3. Constants.printConstants(logger);
  4. logger.warning("No mention finder specified, but not using gold mentions");
  5. runAndScoreCoref(corefSystem, mentionExtractor, props, timeStamp);
  6. } catch (Exception ex) {
  7. logger.log(Level.SEVERE, "ERROR in running coreference", ex);
  8. logger.info("done");
  9. String endTimeStamp = Calendar.getInstance().getTime().toString().replaceAll("\\s", "-");
  10. logger.fine(endTimeStamp);

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Creates a hudson.PluginStrategy, looking at the corresponding system property.
  3. */
  4. protected PluginStrategy createPluginStrategy() {
  5. String strategyName = SystemProperties.getString(PluginStrategy.class.getName());
  6. if (strategyName != null) {
  7. try {
  8. Class<?> klazz = getClass().getClassLoader().loadClass(strategyName);
  9. Object strategy = klazz.getConstructor(PluginManager.class)
  10. .newInstance(this);
  11. if (strategy instanceof PluginStrategy) {
  12. LOGGER.info("Plugin strategy: " + strategyName);
  13. return (PluginStrategy) strategy;
  14. } else {
  15. LOGGER.warning("Plugin strategy (" + strategyName +
  16. ") is not an instance of hudson.PluginStrategy");
  17. }
  18. } catch (ClassNotFoundException e) {
  19. LOGGER.warning("Plugin strategy class not found: "
  20. + strategyName);
  21. } catch (Exception e) {
  22. LOGGER.log(WARNING, "Could not instantiate plugin strategy: "
  23. + strategyName + ". Falling back to ClassicPluginStrategy", e);
  24. }
  25. LOGGER.info("Falling back to ClassicPluginStrategy");
  26. }
  27. // default and fallback
  28. return new ClassicPluginStrategy(this);
  29. }

代码示例来源:origin: peter-lawrey/Java-Chronicle

  1. @Nullable
  2. private SocketChannel createConnection() {
  3. while (!closed) {
  4. try {
  5. readBuffer.clear();
  6. readBuffer.limit(0);
  7. SocketChannel sc = SocketChannel.open(address);
  8. sc.socket().setReceiveBufferSize(256 * 1024);
  9. logger.info("Connected to " + address);
  10. ByteBuffer bb = ByteBuffer.allocate(8);
  11. bb.putLong(0, chronicle.size());
  12. IOTools.writeAllOrEOF(sc, bb);
  13. return sc;
  14. } catch (IOException e) {
  15. if (logger.isLoggable(Level.FINE))
  16. logger.log(Level.FINE, "Failed to connect to " + address + " retrying", e);
  17. else if (logger.isLoggable(Level.INFO))
  18. logger.log(Level.INFO, "Failed to connect to " + address + " retrying " + e);
  19. }
  20. try {
  21. Thread.sleep(500);
  22. } catch (InterruptedException e) {
  23. Thread.currentThread().interrupt();
  24. return null;
  25. }
  26. }
  27. return null;
  28. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. Redwood.startTrack("Adaptor test controlled by redwood");
  2. Logger topLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
  3. topLogger.warning("I'm warning you!");
  4. topLogger.severe("Now I'm using my severe voice.");
  5. topLogger.info("FYI");
  6. topLogger.warning("I'm warning you in Redwood!");
  7. topLogger.info("FYI: Redwood rocks");
  8. } else {
  9. Logger topLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); // Can be Logger.getGlobal() in jdk1.7
  10. Logger logger = Logger.getLogger(JavaUtilLoggingAdaptor.class.getName());
  11. topLogger.info("Starting test");
  12. logger.log(Level.INFO, "Hello from the class logger");
  13. Redwood.log("Hello from Redwood -> Java!");
  14. Redwood.log("Hello from Redwood -> Java again!");
  15. logger.log(Level.INFO, "Hello again from the class logger");
  16. Redwood.startTrack("a track");
  17. Redwood.log("Inside a track");
  18. logger.log(Level.INFO, "Hello a third time from the class logger");
  19. Redwood.endTrack("a track");
  20. logger.log(Level.INFO, "Hello a fourth time from the class logger");

代码示例来源:origin: 4thline/cling

  1. /**
  2. * Called when a received event message could not be parsed successfully.
  3. * <p>
  4. * This typically indicates a broken device which is not UPnP compliant. You can
  5. * react to this failure in any way you like, for example, you could terminate
  6. * the subscription or simply create an error report/log.
  7. * </p>
  8. * <p>
  9. * The default implementation will log the exception at <code>INFO</code> level, and
  10. * the invalid XML at <code>FINE</code> level.
  11. * </p>
  12. *
  13. * @param remoteGENASubscription The established subscription.
  14. * @param ex Call {@link org.fourthline.cling.model.UnsupportedDataException#getData()} to access the invalid XML.
  15. */
  16. protected void invalidMessage(RemoteGENASubscription remoteGENASubscription,
  17. UnsupportedDataException ex) {
  18. log.info("Invalid event message received, causing: " + ex);
  19. if (log.isLoggable(Level.FINE)) {
  20. log.fine("------------------------------------------------------------------------------");
  21. log.fine(ex.getData() != null ? ex.getData().toString() : "null");
  22. log.fine("------------------------------------------------------------------------------");
  23. }
  24. }

代码示例来源:origin: SonarSource/sonarqube

  1. underTest.getRootContext().getLogger(logbackRootLoggerName).addAppender(memoryAppender);
  2. java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("com.ms.sqlserver.jdbc.DTV");
  3. julLogger.finest("Message1");
  4. julLogger.finer("Message1");
  5. julLogger.fine("Message1");
  6. julLogger.info("Message1");
  7. julLogger.warning("Message1");
  8. julLogger.severe("Message1");
  9. julLogger.fine("Message2");
  10. julLogger.info("Message2");
  11. julLogger.warning("Message2");
  12. julLogger.severe("Message2");
  13. assertThat(julLogger.isLoggable(java.util.logging.Level.FINEST)).isTrue();
  14. assertThat(julLogger.isLoggable(java.util.logging.Level.FINER)).isTrue();
  15. assertThat(julLogger.isLoggable(java.util.logging.Level.FINE)).isTrue();
  16. assertThat(julLogger.isLoggable(java.util.logging.Level.INFO)).isTrue();
  17. assertThat(julLogger.isLoggable(java.util.logging.Level.SEVERE)).isTrue();
  18. julLogger.fine("Message3");
  19. julLogger.info("Message3");
  20. julLogger.warning("Message3");
  21. julLogger.severe("Message3");

代码示例来源:origin: apache/ignite

  1. /** {@inheritDoc} */
  2. @Override public void info(String msg) {
  3. if (!impl.isLoggable(INFO))
  4. warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
  5. impl.info(msg);
  6. }

相关文章