org.slf4j.Logger.warn()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(362)

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

Logger.warn介绍

[英]Log a message at the WARN level.
[中]以警告级别记录消息。

代码示例

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

  1. public void updateFailed(Throwable exception) {
  2. // We depend on pending calls to request another metadata update
  3. this.state = State.QUIESCENT;
  4. if (exception instanceof AuthenticationException) {
  5. log.warn("Metadata update failed due to authentication error", exception);
  6. this.authException = (AuthenticationException) exception;
  7. } else {
  8. log.info("Metadata update failed", exception);
  9. }
  10. }

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

  1. /**
  2. * Throw the exception if there is one
  3. */
  4. public static Errors forCode(short code) {
  5. Errors error = codeToError.get(code);
  6. if (error != null) {
  7. return error;
  8. } else {
  9. log.warn("Unexpected error code: {}.", code);
  10. return UNKNOWN_SERVER_ERROR;
  11. }
  12. }

代码示例来源:origin: skylot/jadx

  1. public void printMissingClasses() {
  2. int count = missingClasses.size();
  3. if (count == 0) {
  4. return;
  5. }
  6. LOG.warn("Found {} references to unknown classes", count);
  7. if (LOG.isDebugEnabled()) {
  8. List<String> clsNames = new ArrayList<>(missingClasses);
  9. Collections.sort(clsNames);
  10. for (String cls : clsNames) {
  11. LOG.debug(" {}", cls);
  12. }
  13. }
  14. }
  15. }

代码示例来源:origin: alibaba/jstorm

  1. public void updateStatefulBolt(int taskId, TransactionState state) {
  2. Map<Integer, TransactionState> statefulBoltStates = statefulBolts.get(taskToComponentId.get(taskId));
  3. if (statefulBoltStates.put(taskId, state) != null) {
  4. LOG.warn("Duplicated state commit for statefulBolt-{}, state={}", taskId, state);
  5. } else {
  6. receivedStatefulBoltCount++;
  7. }
  8. }

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

  1. /**
  2. *
  3. * @param rule
  4. * @param applyOrder RoutingRule are applied in order, latter rules can override previous rules
  5. */
  6. public static void registerRule(RoutingRule rule, int applyOrder) {
  7. if (applyOrder > rules.size()) {
  8. logger.warn("apply order " + applyOrder + " is larger than rules size " + rules.size() + ", will put the new rule at the end");
  9. rules.add(rule);
  10. }
  11. rules.add(applyOrder, rule);
  12. }

代码示例来源:origin: Netflix/eureka

  1. private List<AwsEndpoint> getClusterEndpointsFromConfig() {
  2. String[] availZones = clientConfig.getAvailabilityZones(clientConfig.getRegion());
  3. String myZone = InstanceInfo.getZone(availZones, myInstanceInfo);
  4. Map<String, List<String>> serviceUrls = EndpointUtils
  5. .getServiceUrlsMapFromConfig(clientConfig, myZone, clientConfig.shouldPreferSameZoneEureka());
  6. List<AwsEndpoint> endpoints = new ArrayList<>();
  7. for (String zone : serviceUrls.keySet()) {
  8. for (String url : serviceUrls.get(zone)) {
  9. try {
  10. endpoints.add(new AwsEndpoint(url, getRegion(), zone));
  11. } catch (Exception ignore) {
  12. logger.warn("Invalid eureka server URI: {}; removing from the server pool", url);
  13. }
  14. }
  15. }
  16. logger.debug("Config resolved to {}", endpoints);
  17. if (endpoints.isEmpty()) {
  18. logger.error("Cannot resolve to any endpoints from provided configuration: {}", serviceUrls);
  19. }
  20. return endpoints;
  21. }

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

  1. private boolean emitRecord (SpoutOutputCollector collector, Record record, KinesisMessageId kinesisMessageId) {
  2. boolean result = false;
  3. List<Object> tuple = kinesisConfig.getRecordToTupleMapper().getTuple(record);
  4. // if a record is returned put the sequence number in the emittedPerShard to tie back with ack or fail
  5. if (tuple != null && tuple.size() > 0) {
  6. collector.emit(tuple, kinesisMessageId);
  7. if (!emittedPerShard.containsKey(kinesisMessageId.getShardId())) {
  8. emittedPerShard.put(kinesisMessageId.getShardId(), new TreeSet<BigInteger>());
  9. }
  10. emittedPerShard.get(kinesisMessageId.getShardId()).add(new BigInteger(record.getSequenceNumber()));
  11. result = true;
  12. } else {
  13. // ack to not process the record again on restart and move on to next message
  14. LOG.warn("Record " + record + " did not return a tuple to emit. Hence acking it");
  15. ack(kinesisMessageId);
  16. }
  17. return result;
  18. }

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

  1. @Override
  2. public void log (int level, String category, String message, Throwable ex) {
  3. final String logString = "[KRYO " + category + "] " + message;
  4. switch (level) {
  5. case Log.LEVEL_ERROR:
  6. log.error(logString, ex);
  7. break;
  8. case Log.LEVEL_WARN:
  9. log.warn(logString, ex);
  10. break;
  11. case Log.LEVEL_INFO:
  12. log.info(logString, ex);
  13. break;
  14. case Log.LEVEL_DEBUG:
  15. log.debug(logString, ex);
  16. break;
  17. case Log.LEVEL_TRACE:
  18. log.trace(logString, ex);
  19. break;
  20. }
  21. }
  22. }

代码示例来源:origin: Graylog2/graylog2-server

  1. public void setMessage(String id, Map<String, Object> message) {
  2. Map<String, Object> tmp = Maps.newHashMap();
  3. tmp.putAll(message);
  4. tmp.put(Message.FIELD_ID, id);
  5. if (tmp.containsKey(Message.FIELD_TIMESTAMP)) {
  6. final Object tsField = tmp.get(Message.FIELD_TIMESTAMP);
  7. try {
  8. tmp.put(Message.FIELD_TIMESTAMP, ES_DATE_FORMAT_FORMATTER.parseDateTime(String.valueOf(tsField)));
  9. } catch (IllegalArgumentException e) {
  10. // could not parse date string, this is likely a bug, but we will leave the original value alone
  11. LOG.warn("Could not parse timestamp of message {}", message.get("id"), e);
  12. }
  13. }
  14. this.message = new Message(tmp);
  15. }

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

  1. public List<HBMessage> sendAll(HBMessage m) throws PacemakerConnectionException, InterruptedException {
  2. List<HBMessage> responses = new ArrayList<HBMessage>();
  3. LOG.debug("Using servers: {}", servers);
  4. for (String s : servers) {
  5. try {
  6. HBMessage response = getClientForServer(s).send(m);
  7. responses.add(response);
  8. } catch (PacemakerConnectionException e) {
  9. LOG.warn("Failed to connect to the pacemaker server {}, attempting to reconnect", s);
  10. getClientForServer(s).reconnect();
  11. }
  12. }
  13. if (responses.size() == 0) {
  14. throw new PacemakerConnectionException("Failed to connect to any Pacemaker.");
  15. }
  16. return responses;
  17. }

代码示例来源:origin: skylot/jadx

  1. if (argsTypes.size() != mthArgs.size()) {
  2. if (argsTypes.isEmpty()) {
  3. return false;
  4. LOG.warn("Wrong signature parse result: {} -> {}, not generic version: {}", sp, argsTypes, mthArgs);
  5. return false;
  6. } else if (getParentClass().getAccessFlags().isEnum()) {
  7. argsTypes.add(0, mthArgs.get(0));
  8. argsTypes.add(1, mthArgs.get(1));
  9. } else {
  10. argsTypes.add(0, mthArgs.get(0));
  11. if (argsTypes.size() != mthArgs.size()) {
  12. return false;
  13. return true;
  14. } catch (JadxRuntimeException e) {
  15. LOG.error("Method signature parse error: {}", this, e);
  16. return false;

代码示例来源:origin: skylot/jadx

  1. public void printReport() {
  2. if (getErrorCount() > 0) {
  3. LOG.error("{} errors occurred in following nodes:", getErrorCount());
  4. List<String> errors = new ArrayList<>(errorNodes.size());
  5. for (IAttributeNode node : errorNodes) {
  6. String nodeName = node.getClass().getSimpleName().replace("Node", "");
  7. errors.add(nodeName + ": " + node);
  8. }
  9. Collections.sort(errors);
  10. for (String err : errors) {
  11. LOG.error(" {}", err);
  12. }
  13. }
  14. if (getWarnsCount() > 0) {
  15. LOG.warn("{} warnings in {} nodes", getWarnsCount(), warnNodes.size());
  16. }
  17. }
  18. }

代码示例来源:origin: ch.qos.logback/logback-classic

  1. public void close() {
  2. closed = true;
  3. if (serverSocket != null) {
  4. try {
  5. serverSocket.close();
  6. } catch (IOException e) {
  7. logger.error("Failed to close serverSocket", e);
  8. } finally {
  9. serverSocket = null;
  10. }
  11. }
  12. logger.info("closing this server");
  13. synchronized (socketNodeList) {
  14. for (SocketNode sn : socketNodeList) {
  15. sn.close();
  16. }
  17. }
  18. if (socketNodeList.size() != 0) {
  19. logger.warn("Was expecting a 0-sized socketNodeList after server shutdown");
  20. }
  21. }

代码示例来源:origin: Atmosphere/atmosphere

  1. public static void interceptorsForHandler(AtmosphereFramework framework, List<Class<? extends AtmosphereInterceptor>> interceptors, List<AtmosphereInterceptor> l) {
  2. for (Class<? extends AtmosphereInterceptor> i : interceptors) {
  3. if (!framework.excludedInterceptors().contains(i.getName())
  4. && (!AtmosphereFramework.DEFAULT_ATMOSPHERE_INTERCEPTORS.contains(i))) {
  5. try {
  6. logger.info("Adding {}", i);
  7. l.add(framework.newClassInstance(AtmosphereInterceptor.class, i));
  8. } catch (Throwable e) {
  9. logger.warn("", e);
  10. }
  11. }
  12. }
  13. }

代码示例来源:origin: eirslett/frontend-maven-plugin

  1. @Override
  2. protected void processLine(final String line, final int logLevel) {
  3. if (logLevel == 0) {
  4. logger.info(line);
  5. } else {
  6. if (line.startsWith("npm WARN ")) {
  7. logger.warn(line);
  8. } else {
  9. logger.error(line);
  10. }
  11. }
  12. }
  13. }

代码示例来源:origin: thinkaurelius/titan

  1. private int getRoundsForFullMethodName(String fullname) {
  2. Integer r = efforts.get(fullname);
  3. if (null == r) {
  4. r = DEFAULT_ROUNDS;
  5. log.warn("Applying default iteration count ({}) to method {}", r, fullname);
  6. } else {
  7. log.debug("Loaded iteration count {} on method {}", r, fullname);
  8. }
  9. return r;
  10. }
  11. }

代码示例来源:origin: Graylog2/graylog2-server

  1. private List<Converter> loadConverters(Map<String, Map<String, Object>> requestConverters) {
  2. List<Converter> converters = Lists.newArrayList();
  3. for (Map.Entry<String, Map<String, Object>> c : requestConverters.entrySet()) {
  4. try {
  5. converters.add(converterFactory.create(Converter.Type.valueOf(c.getKey().toUpperCase(Locale.ENGLISH)), c.getValue()));
  6. } catch (ConverterFactory.NoSuchConverterException e) {
  7. LOG.warn("No such converter [" + c.getKey() + "]. Skipping.", e);
  8. } catch (ConfigurationException e) {
  9. LOG.warn("Missing configuration for [" + c.getKey() + "]. Skipping.", e);
  10. }
  11. }
  12. return converters;
  13. }

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

  1. @Override
  2. public synchronized void shutdown() {
  3. if (!canShutdown()) {
  4. LOG.debug("ZooKeeper server is not running, so not proceeding to shutdown!");
  5. return;
  6. }
  7. LOG.info("Shutting down");
  8. try {
  9. super.shutdown();
  10. } catch (Exception e) {
  11. LOG.warn("Ignoring unexpected exception during shutdown", e);
  12. }
  13. try {
  14. if (syncProcessor != null) {
  15. syncProcessor.shutdown();
  16. }
  17. } catch (Exception e) {
  18. LOG.warn("Ignoring unexpected exception in syncprocessor shutdown",
  19. e);
  20. }
  21. }
  22. }

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

  1. protected boolean runImpl() {
  2. try {
  3. Message message = consumer.receive();
  4. if (message == null) {
  5. LOG.debug("Message consumer was closed.");
  6. return true;
  7. }
  8. ObjectMessage omessage = (ObjectMessage) message;
  9. daemonThreadStatsCollector.captureStats(thread.getId());
  10. listener.onMessage((GoMessage) omessage.getObject());
  11. } catch (JMSException e) {
  12. LOG.warn("Error receiving message. Message receiving will continue despite this error.", e);
  13. } catch (Exception e) {
  14. LOG.error("Exception thrown in message handling by listener {}", listener, e);
  15. } finally {
  16. daemonThreadStatsCollector.clearStats(thread.getId());
  17. }
  18. return false;
  19. }

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

  1. @Override
  2. public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
  3. if (cause instanceof ConnectException) {
  4. LOG.warn("Connection to pacemaker failed. Trying to reconnect {}", cause.getMessage());
  5. } else {
  6. LOG.error("Exception occurred in Pacemaker.", cause);
  7. }
  8. client.reconnect();
  9. }
  10. }

相关文章