org.apache.log4j.Logger.info()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(201)

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

Logger.info介绍

[英]Log a message with the INFO level with message formatting done according to the value of messagePattern and arg parameters.

This form avoids superflous parameter construction. Whenever possible, you should use this form instead of constructing the message parameter using string concatenation.
[中]使用INFO级别记录消息,并根据messagePatternarg参数的值设置消息格式。
这种形式避免了超级参数构造。只要有可能,您应该使用此表单,而不是使用字符串连接构造消息参数。

代码示例

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

public void waitForResponse(int timeoutMills) {
  long startTime = System.currentTimeMillis();
  while (this.successSendResult.size() != this.msgSize) {
    if (System.currentTimeMillis() - startTime < timeoutMills) {
      TestUtil.waitForMonment(100);
    } else {
      logger.info("timeout but still not recv all response!");
      break;
    }
  }
}

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

private void cleanOldExecutionLogs(final long millis) {
 final long beforeDeleteLogsTimestamp = System.currentTimeMillis();
 try {
  final int count = this.executorLoader.removeExecutionLogsByTime(millis);
  logger.info("Cleaned up " + count + " log entries.");
 } catch (final ExecutorManagerException e) {
  logger.error("log clean up failed. ", e);
 }
 logger.info(
   "log clean up time: " + (System.currentTimeMillis() - beforeDeleteLogsTimestamp) / 1000
     + " seconds.");
}

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

private Socket applySettings(Socket s) throws IOException {
  if(logger.isDebugEnabled())
    logger.debug("Attempting to set socket receive buffer of "
           + this.socketReceiveBufferSize + " bytes");
  s.setReceiveBufferSize(socketReceiveBufferSize);
  s.setSoTimeout(socketTimeout);
  if(logger.isDebugEnabled())
    logger.info("Actually set socket receive buffer to " + s.getReceiveBufferSize()
          + " bytes");
  return s;
}

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

public void run() {
    try {
      DataSetStats totals = new DataSetStats();
      List<String> names = new ArrayList<String>();
      List<DataSetStats> stats = new ArrayList<DataSetStats>();
      for(StorageEngine<ByteArray, byte[], byte[]> store: storeRepository.getAllStorageEngines()) {
        if(store instanceof ReadOnlyStorageEngine
          || store instanceof ViewStorageEngine || store instanceof MetadataStore)
          continue;
        logger.info(store.getClass());
        logger.info("Calculating stats for '" + store.getName() + "'...");
        DataSetStats curr = calculateStats(store);
        names.add(store.getName());
        stats.add(curr);
        totals.add(curr);
      }
      for(int i = 0; i < names.size(); i++)
        logger.info("\n\nData statistics for store '" + names.get(i) + "':\n"
              + stats.get(i) + "\n\n");
      logger.info("Totals: \n " + totals + "\n\n");
    } catch(Exception e) {
      logger.error("Error in thread: ", e);
    }
  }
});

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

boolean details) {
if(logger.isInfoEnabled()) {
  logger.info("Connecting to bootstrap server: " + url);
  if(storeNames != null) {
    if(!storeNames.contains(storeName)) {
      logger.debug("Will not sample store "
             + storeName
             + " since it is not in list of storeNames provided on command line.");
  for(String storeName: storeNames) {
    if(!this.storeNamesSet.contains(storeName)) {
      badStoreNames.add(storeName);
  if(badStoreNames.size() > 0) {
    Utils.croak("Some storeNames provided on the command line were not found on this cluster: "
          + badStoreNames);

代码示例来源:origin: apache/incubator-gobblin

private List<Long> getValidationOutputFromHive(List<String> queries) throws IOException {
   Path hiveTempDir = new Path("/tmp" + Path.SEPARATOR + hiveOutput);
   query = "INSERT OVERWRITE DIRECTORY '" + hiveTempDir + "' " + query;
   log.info("Executing query: " + query);
   try {
    if (this.hiveSettings.size() > 0) {
     hiveJdbcConnector.executeStatements(this.hiveSettings.toArray(new String[this.hiveSettings.size()]));
    if (files.size() > 1) {
     log.warn("Found more than one output file. Should have been one.");
    } else if (files.size() == 0) {
     log.warn("Found no output file. Should have been one.");
    } else {
     String theString = IOUtils.toString(new InputStreamReader(this.fs.open(files.get(0).getPath()), Charsets.UTF_8));
     log.info("Found row count: " + theString.trim());
     if (StringUtils.isBlank(theString.trim())) {
      rowCounts.add(0l);
     } else {
      try {
       rowCounts.add(Long.parseLong(theString.trim()));
      } catch (NumberFormatException e) {
       throw new RuntimeException("Could not parse Hive output: " + theString.trim(), e);
     log.debug("Deleting temp dir: " + hiveTempDir);
     this.fs.delete(hiveTempDir, true);

代码示例来源:origin: RipMeApp/ripme

public List<String> getTags(Document doc) {
  List<String> tags = new ArrayList<>();
  LOGGER.info("Getting tags");
  for (Element tag : doc.select("td > div > a")) {
    LOGGER.info("Found tag " + tag.text());
    tags.add(tag.text());
  }
  return tags;
}

代码示例来源:origin: apache/incubator-gobblin

private static void getOtherNamenodesToken(List<String> otherNamenodes, Configuration conf, Credentials cred)
  throws IOException {
 LOG.info(OTHER_NAMENODES + ": " + otherNamenodes);
 Path[] ps = new Path[otherNamenodes.size()];
 for (int i = 0; i < ps.length; i++) {
  ps[i] = new Path(otherNamenodes.get(i).trim());
 }
 TokenCache.obtainTokensForNamenodes(cred, ps, conf);
 LOG.info("Successfully fetched tokens for: " + otherNamenodes);
}

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

private void printRemainingTasks(List<Integer> stealerIds) {
  for(int stealerId: stealerIds) {
    List<Integer> donorIds = new ArrayList<Integer>();
    for(StealerBasedRebalanceTask sbTask: tasksByStealer.get(stealerId)) {
      int donorId = sbTask.getStealInfos().get(0).getDonorId();
      donorIds.add(donorId);
    }
    logger.info(" Remaining work for Stealer " + stealerId + " Donors : " + donorIds);
  }
}

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

private void commitToVoldemort(List<String> storeNamesToCommit) {
  if(logger.isDebugEnabled()) {
    logger.debug("Trying to commit to Voldemort");
  if(nodesToStream == null || nodesToStream.size() == 0) {
    if(logger.isDebugEnabled()) {
      logger.debug("No nodes to stream to. Returning.");
        logger.error("Exception during commit", e);
        hasError = true;
        if(!faultyNodes.contains(node.getId()))
          faultyNodes.add(node.getId());
    logger.warn("StreamingSession may not have been initialized since Variable streamingresults is null. Skipping callback ");
    return;
    logger.info("Invoking the Recovery Callback");
    Future future = streamingresults.submit(recoveryCallback);
    try {
    if(logger.isDebugEnabled()) {
      logger.debug("Commit successful");
      logger.debug("calling checkpoint callback");
      logger.warn("Checkpoint callback failed!", e1);
    } catch(ExecutionException e1) {
      logger.warn("Checkpoint callback failed during execution!", e1);

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

Versioned<String> storesValue) {
if (remoteNodeIds == null || remoteNodeIds.size() == 0) {
  throw new IllegalArgumentException("One ore more nodes expected for NodeIds");
  logger.info("Setting " + clusterKey + " and " + storesKey + " for "
        + getAdminClientCluster().getNodeById(currentNodeId).getHost() + ":"
        + getAdminClientCluster().getNodeById(currentNodeId).getId());
    try {
      for(StoreDefinition storeDef: storeDefs) {
        storeNames.add(storeDef.getName());

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

public Collection<Object> waitForMessageConsume(Collection<Object> allSendMsgs,
  int timeoutMills) {
  this.allSendMsgs = allSendMsgs;
  List<Object> sendMsgs = new ArrayList<Object>();
  sendMsgs.addAll(allSendMsgs);
  long curTime = System.currentTimeMillis();
  while (!sendMsgs.isEmpty()) {
    Iterator<Object> iter = sendMsgs.iterator();
    while (iter.hasNext()) {
      Object msg = iter.next();
      if (msgBodys.getAllData().contains(msg)) {
        iter.remove();
      }
    }
    if (sendMsgs.isEmpty()) {
      break;
    } else {
      if (System.currentTimeMillis() - curTime >= timeoutMills) {
        logger.error(String.format("timeout but  [%s]  not recv all send messages!",
          listenerName));
        break;
      } else {
        logger.info(String.format("[%s] still [%s] msg not recv!", listenerName,
          sendMsgs.size()));
        TestUtil.waitForMonment(500);
      }
    }
  }
  return sendMsgs;
}

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

private void registerMbean(final String name, final Object mbean) {
 final Class<?> mbeanClass = mbean.getClass();
 final ObjectName mbeanName;
 try {
  mbeanName = new ObjectName(mbeanClass.getName() + ":name=" + name);
  this.mbeanServer.registerMBean(mbean, mbeanName);
  logger.info("Bean " + mbeanClass.getCanonicalName() + " registered.");
  this.registeredMBeans.add(mbeanName);
 } catch (final Exception e) {
  logger.error("Error registering mbean " + mbeanClass.getCanonicalName(),
    e);
 }
}

代码示例来源:origin: apache/incubator-gobblin

final long updateTime = this.updateProvider.getUpdateTime(sourcePartition);
  if (shouldValidate(sourcePartition)) {
   log.info(String.format("Validating partition: %s", sourcePartition.getCompleteName()));
       .getDbName(), destinationMeta.getKey().get(), Optional.of(sourcePartition), this.isNestedORC));
   this.futures.add(this.exec.submit(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
   log.debug(String.format("Not validating partition: %s as updateTime: %s is not in range of max look back: %s " + "and skip recent than: %s",
     sourcePartition.getCompleteName(), updateTime, this.maxLookBackTime, this.skipRecentThanTime));
  log.warn(
    String.format("Not validating partition: %s %s", sourcePartition.getCompleteName(), e.getMessage()));
 } catch (UpdateNotFoundException e) {
  log.warn(String.format("Not validating partition: %s as update time was not found. %s",
    sourcePartition.getCompleteName(), e.getMessage()));
log.info(String.format("No conversion config found for format %s. Ignoring data validation", format));

代码示例来源:origin: RipMeApp/ripme

@Override
public void rip() throws IOException {
  int index = 0;
  LOGGER.info("Retrieving " + this.url);
  sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
  JSONObject json = getFirstPage();
      while (imageURLs.size() > 1) {
        imageURLs.remove(1);
      LOGGER.debug("Found image url #" + index+ ": " + imageURL);
      downloadURL(new URL(imageURL), index);
      json = getNextPage(json);
    } catch (IOException e) {
      LOGGER.info("Can't get next page: " + e.getMessage());
      break;
    LOGGER.debug("Waiting for threadpool " + getThreadPool().getClass().getName());
    getThreadPool().waitForThreads();

代码示例来源:origin: h2oai/h2o-2

org.apache.log4j.Logger httpdLogger = LogManager.getLogger("water.api.RequestServer");
if (e.kind == Kind.INFO) {
 httpdLogger.info(s);
 httpdLogger.error(s);
l4j.error(s);
l4j.warn(s);
l4j.info(s);
l4j.debug(s);
l4j.error(s);

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

/** Listens for client connections **/
  public void run() {
    LOG.info("Thread started");
    try {
      while (true) {
        LOG.debug("Waiting for a connection");
        final Socket client = mSvrSock.accept();
        LOG.debug("Got a connection from " +
             client.getInetAddress().getHostName());
        final Thread t = new Thread(new Slurper(client));
        t.setDaemon(true);
        t.start();
      }
    } catch (IOException e) {
      LOG.error("Error in accepting connections, stopping.", e);
    }
  }
}

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

static
 void roll() {
  try {
   Socket socket = new Socket(host, port);
   DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
   DataInputStream dis = new DataInputStream(socket.getInputStream());
   dos.writeUTF(ExternallyRolledFileAppender.ROLL_OVER);
   String rc = dis.readUTF();
   if(ExternallyRolledFileAppender.OK.equals(rc)) {
  cat.info("Roll over signal acknowledged by remote appender.");
   } else {
  cat.warn("Unexpected return code "+rc+" from remote entity.");
  System.exit(2);
   }
  } catch(IOException e) {
   cat.error("Could not send roll signal on host "+host+" port "+port+" .",
    e);
   System.exit(2);
  }
  System.exit(0);
 }
}

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

/** loops getting the events **/
  public void run() {
    LOG.debug("Starting to get data");
    try {
      final ObjectInputStream ois =
        new ObjectInputStream(mClient.getInputStream());
      while (true) {
        final LoggingEvent event = (LoggingEvent) ois.readObject();
        mModel.addEvent(new EventDetails(event));
      }
    } catch (EOFException e) {
      LOG.info("Reached EOF, closing connection");
    } catch (SocketException e) {
      LOG.info("Caught SocketException, closing connection");
    } catch (IOException e) {
      LOG.warn("Got IOException, closing connection", e);
    } catch (ClassNotFoundException e) {
      LOG.warn("Got ClassNotFoundException, closing connection", e);
    }
    try {
      mClient.close();
    } catch (IOException e) {
      LOG.warn("Error closing connection", e);
    }
  }
}

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

/**
 * Prompts the user for a file to load events from.
 * @param aIgnore an <code>ActionEvent</code> value
 */
public void actionPerformed(ActionEvent aIgnore) {
  LOG.info("load file called");
  if (mChooser.showOpenDialog(mParent) == JFileChooser.APPROVE_OPTION) {
    LOG.info("Need to load a file");
    final File chosen = mChooser.getSelectedFile();
    LOG.info("loading the contents of " + chosen.getAbsolutePath());
    try {
      final int num = loadFile(chosen.getAbsolutePath());
      JOptionPane.showMessageDialog(
        mParent,
        "Loaded " + num + " events.",
        "CHAINSAW",
        JOptionPane.INFORMATION_MESSAGE);
    } catch (Exception e) {
      LOG.warn("caught an exception loading the file", e);
      JOptionPane.showMessageDialog(
        mParent,
        "Error parsing file - " + e.getMessage(),
        "CHAINSAW",
        JOptionPane.ERROR_MESSAGE);
    }
  }
}

相关文章