当前位置: 首页>>代码示例>>Java>>正文


Java Logger.info方法代码示例

本文整理汇总了Java中org.slf4j.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.info方法的具体用法?Java Logger.info怎么用?Java Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.slf4j.Logger的用法示例。


在下文中一共展示了Logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dump

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * 记录请求信息
 * 
 * @param methodInvocation
 * @param take
 */
private void dump(MethodInvocation methodInvocation, Object result, long take) {
    // 取得日志打印对象
    Logger log = getLogger(methodInvocation.getMethod().getDeclaringClass());
    Object[] args = methodInvocation.getArguments();
    StringBuffer buffer = getArgsString(args);

    if (log.isInfoEnabled()) {
        String className = ClassUtils.getShortClassName(methodInvocation.getMethod().getDeclaringClass());
        String methodName = methodInvocation.getMethod().getName();
        String resultStr = getResultString(result);

        String now = new SimpleDateFormat(DATA_FORMAT).format(new Date());
        log.info(MessageFormat.format(MESSAGE, new Object[] { className, methodName, now, take, buffer.toString(),
                resultStr }));
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:LogInterceptor.java

示例2: isClassOk

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * Check to see if a class is well-formed.
 *
 * @param logger the logger to write to if a problem is found
 * @param logTag a tag to print to the log if a problem is found
 * @param classNode the class to check
 * @return true if the class is ok, false otherwise
 */
public static boolean isClassOk(final Logger logger, final String logTag, final ClassNode classNode) {
  final StringWriter sw = new StringWriter();
  final ClassWriter verifyWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
  classNode.accept(verifyWriter);
  final ClassReader ver = new ClassReader(verifyWriter.toByteArray());
  try {
    DrillCheckClassAdapter.verify(ver, false, new PrintWriter(sw));
  } catch(final Exception e) {
    logger.info("Caught exception verifying class:");
    logClass(logger, logTag, classNode);
    throw e;
  }
  final String output = sw.toString();
  if (!output.isEmpty()) {
    logger.info("Invalid class:\n" +  output);
    return false;
  }

  return true;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:29,代码来源:AsmUtil.java

示例3: logCommands

import org.slf4j.Logger; //导入方法依赖的package包/类
public static void logCommands(List<String> commands) {
    Logger log = LoggerFactory.getLogger(CommandUtil.class);
    log.info("commands ----");
    String formatter = "%0" + String.valueOf(commands.size()).length() + "d";
    int line = 0;
    for (String command : commands) {
        line++;
        if (command == null) {
            command = "";
        } else if (command.contains("パスワード")) {
            command = escape(command, "パスワード");
        } else if (command.toLowerCase().contains("password")) {
            command = escape(command, "password");
        }
        log.info("[" + String.format(formatter, Integer.valueOf(line)) + "] " + command);
    }
    log.info("----");
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:19,代码来源:CommandUtil.java

示例4: main

import org.slf4j.Logger; //导入方法依赖的package包/类
public static void main(String[] args) {
	Logger logger = LoggerFactory.getLogger(GetSomeAFPData.class);

	Proxy proxy = null;
	// If you are behind a proxy, use the following line with the correct parameters :
	// proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("firewall.company.com", 80));

	Map<String, String> authentication = null;
	// If you want to use your credentials on api.afp.com, provide the following informations :
	// authentication = new HashMap<String, String>();
	// authentication.put(AFPAuthenticationManager.KEY_CLIENT, "client");
	// authentication.put(AFPAuthenticationManager.KEY_SECRET, "secret");
	// authentication.put(AFPAuthenticationManager.KEY_USERNAME, "username");
	// authentication.put(AFPAuthenticationManager.KEY_PASSWORD, "password");

	AFPDataGrabber afp = new AFPDataGrabber(LangEnum.EN, authentication, logger, dataDir,
			AFPDataGrabberCache.noCache(), proxy);

	AFPGrabSession gs = afp.grabSearchMax(false, 10);
	logger.info("Grabbed " + gs.getAllDocuments().size() + " documents as [" + gs.getAuthenticatedAs() + "] in "
			+ gs.getDir());
	for (FullNewsDocument nd : gs.getAllDocuments()) {
		logger.info("    - " + nd.getUno() + " : " + nd.getFullTitle());
	}
}
 
开发者ID:ina-foss,项目名称:afp-api-client,代码行数:26,代码来源:GetSomeAFPData.java

示例5: buildToDockerfile

import org.slf4j.Logger; //导入方法依赖的package包/类
public void buildToDockerfile(TransformationContext context, BaseImageMapper mapper) throws IOException {
    Logger logger = context.getLogger(NodeStack.class);
    ImageMappingVisitor mappingVisitor = new ImageMappingVisitor(mapper);
    for (int i = stackNodes.size() - 1; i >= 0; i--) {
        KubernetesNodeContainer c = stackNodes.get(i);
        c.getNode().accept(mappingVisitor);
    }

    if (!mappingVisitor.getBaseImage().isPresent()) {
        throw new UnsupportedOperationException("Transformation of the Stack " + this + " is not possible!");
    }
    String baseImage = mappingVisitor.getBaseImage().get();
    logger.info("Determined Base Image {} for stack {}", baseImage, this);

    DockerfileBuildingVisitor visitor = new DockerfileBuildingVisitor(baseImage, this, context);
    visitor.buildAndWriteDockerfile();
    this.openPorts.addAll(visitor.getPorts());
    dockerfilePath = "output/docker/" + getStackName();
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:20,代码来源:NodeStack.java

示例6: resetOffsetByTimestamp

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * Reset consumer topic offset according to time
 *
 * @param messageModel which model
 * @param instanceName which instance
 * @param consumerGroup consumer group
 * @param topic topic
 * @param timestamp time
 * @throws Exception
 */
public static void resetOffsetByTimestamp(
    final MessageModel messageModel,
    final String instanceName,
    final String consumerGroup,
    final String topic,
    final long timestamp) throws Exception {
    final Logger log = ClientLogger.getLog();

    DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup);
    consumer.setInstanceName(instanceName);
    consumer.setMessageModel(messageModel);
    consumer.start();

    Set<MessageQueue> mqs = null;
    try {
        mqs = consumer.fetchSubscribeMessageQueues(topic);
        if (mqs != null && !mqs.isEmpty()) {
            TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs);
            for (MessageQueue mq : mqsNew) {
                long offset = consumer.searchOffset(mq, timestamp);
                if (offset >= 0) {
                    consumer.updateConsumeOffset(mq, offset);
                    log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}",
                        consumerGroup, offset, mq);
                }
            }
        }
    } catch (Exception e) {
        log.warn("resetOffsetByTimestamp Exception", e);
        throw e;
    } finally {
        if (mqs != null) {
            consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs);
        }
        consumer.shutdown();
    }
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:48,代码来源:MQHelper.java

示例7: run

import org.slf4j.Logger; //导入方法依赖的package包/类
public void run() {
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.info("Executing shutdown hook.");

    logger.info("Stopping plugins.");
    for(PluginBubble bubble : Sagiri.getPlugins()) {
        bubble.getPlugin().stop();
        logger.info(String.format("Stopped plugin: %s", bubble.getName()));
    }
}
 
开发者ID:kazigk,项目名称:sagiri,代码行数:11,代码来源:ShutdownHook.java

示例8: getUpdateObservable

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * Gets update observable.
 *
 * @return the update observable
 */
public static Observable<IUpdate> getUpdateObservable() {
    if (UpdateObservable == null) {
        Logger.info("Update Observable wasn't created yet, creating now...");
        createObservable();
    }
    return UpdateObservable;
}
 
开发者ID:iSDP,项目名称:Telebot,代码行数:13,代码来源:Telebot.java

示例9: fetchAmazonDiscsData

import org.slf4j.Logger; //导入方法依赖的package包/类
private void fetchAmazonDiscsData(int retry) {
    Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
    if (retry == 0) {
        if (logger.isWarnEnabled()) {
            logger.warn("fetching amazon discs data failed");
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("fetching amazon discs data ({})", retry);
        }
        try {
            amazonDiscsSpider.fetch();
        } catch (IOException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("fetching amazon discs data throw an error", e);
            }
            if (retry > 0) {
                fetchSakuraSpeedData(retry - 1);
            } else {
                return;
            }
        }
        if (logger.isInfoEnabled()) {
            logger.info("fetched amazon discs data ({})", retry);
        }
    }
}
 
开发者ID:mingzuozhibi,项目名称:mzzb-server,代码行数:28,代码来源:AutoRunConfig.java

示例10: write

import org.slf4j.Logger; //导入方法依赖的package包/类
public static void write(Class clazz, LogLevel logLevel, String message) {
    Logger logger = LoggerFactory.getLogger(clazz);

    switch (logLevel) {
    case TRACE:
        logger.trace(message);
        break;
    case DEBUG:
        logger.debug(message);
        break;
    case INFO:
        logger.info(message);
        break;
    case WARN:
        logger.warn(message);
        break;
    case ERROR:
        logger.error(message);
        break;
    case FATAL:
        Marker marker = MarkerFactory.getMarker("FATAL");
        logger.error(marker, message);
        break;
    default:
        logger.warn("No suitable log level found");
        break;
    }
}
 
开发者ID:voyages-sncf-technologies,项目名称:cerebro,代码行数:29,代码来源:LogWriter.java

示例11: Launchpad

import org.slf4j.Logger; //导入方法依赖的package包/类
Launchpad(File profilePath) throws LaunchpadException {
  if (! profilePath.exists()) {
    throw new LaunchpadException("Profile path " + profilePath + " does not exist", null);
  }
  
  if (! profilePath.isDirectory()) {
    throw new LaunchpadException("Profile path must be a directory", null);
  }
  
  final File profileYaml = new File(profilePath.getPath() + "/profile.yaml");
  if (! profileYaml.exists()) {
    throw new LaunchpadException("Profile configuration " + profileYaml + " is missing", null);
  }

  profile = rethrowLaunchpadException(() -> {
    return Profile.fromFile(profileYaml);
  }, "Error reading profile");
  
  final StringBuilder sb = new StringBuilder();
  
  rethrowLaunchpadException(() -> {
    sb.append("\n  Flywheel version: ").append(FlywheelVersion.get());
    sb.append("\n  Indigo version: ").append(IndigoVersion.get());
  }, "Error retrieving version"); 
  
  sb.append("\n  Properties:");
  for (Map.Entry<String, ?> entry : profile.properties.entrySet()) {
    sb.append("\n    ").append(entry.getKey()).append(": ").append(entry.getValue());
  }
  
  sb.append("\n  Launchers:");
  for (Launcher launcher : profile.launchers) {
    sb.append("\n    ").append(launcher);
  }
  
  final Logger log = LoggerFactory.getLogger(Launchpad.class);
  log.info(sb.toString());
}
 
开发者ID:William-Hill-Community,项目名称:flywheel,代码行数:39,代码来源:Launchpad.java

示例12: logReq

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * Print logs of http request.
 */
public static void logReq(Logger logger, HttpServletRequest req) {
    String queryStr = req.getQueryString();
    if (queryStr == null || queryStr.length() == 0) {
        logger.info(req.getMethod() + " " + req.getRequestURI());
    } else {
        try {
            queryStr = URLDecoder.decode(queryStr, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            logger.warn(e.getMessage());
        }
        logger.info(req.getMethod() + " " + req.getRequestURI() + "?" + queryStr);
    }
}
 
开发者ID:AwesomeTickets,项目名称:ServiceServer,代码行数:17,代码来源:LogUtil.java

示例13: printObjectProperties

import org.slf4j.Logger; //导入方法依赖的package包/类
public static void printObjectProperties(final Logger log, final Object object, final boolean onlyImportantField) {
    Field[] fields = object.getClass().getDeclaredFields();
    for (Field field : fields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            String name = field.getName();
            if (!name.startsWith("this")) {
                Object value = null;
                try {
                    field.setAccessible(true);
                    value = field.get(object);
                    if (null == value) {
                        value = "";
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }

                if (onlyImportantField) {
                    Annotation annotation = field.getAnnotation(ImportantField.class);
                    if (null == annotation) {
                        continue;
                    }
                }

                if (log != null) {
                    log.info(name + "=" + value);
                }
            }
        }
    }
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:32,代码来源:MixAll.java

示例14: build

import org.slf4j.Logger; //导入方法依赖的package包/类
/**
 * builds a user exception or returns the wrapped one. If the error is a system error, the error message is logged
 * to the given {@link Logger}.
 *
 * @param logger the logger to write to
 * @return user exception
 */
public UserException build(final Logger logger) {
  if (uex != null) {
    return uex;
  }

  boolean isSystemError = errorType == DrillPBError.ErrorType.SYSTEM;

  // make sure system errors use the root error message and display the root cause class name
  if (isSystemError) {
    message = ErrorHelper.getRootMessage(cause);
  }

  final UserException newException = new UserException(this);

  // since we just created a new exception, we should log it for later reference. If this is a system error, this is
  // an issue that the Drill admin should pay attention to and we should log as ERROR. However, if this is a user
  // mistake or data read issue, the system admin should not be concerned about these and thus we'll log this
  // as an INFO message.
  if (isSystemError) {
    logger.error(newException.getMessage(), newException);
  } else {
    logger.info("User Error Occurred", newException);
  }

  return newException;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:34,代码来源:UserException.java

示例15: starting

import org.slf4j.Logger; //导入方法依赖的package包/类
@Override
protected void starting(Description description) {
    final Logger logger = LoggerFactory.getLogger(description.getTestClass());
    logger.info("Start of '{}'...", description.getMethodName());
}
 
开发者ID:e-Spirit,项目名称:FSTestTools,代码行数:6,代码来源:LogTestMethodNameRule.java


注:本文中的org.slf4j.Logger.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。