本文整理匯總了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 }));
}
}
示例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;
}
示例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("----");
}
示例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());
}
}
示例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();
}
示例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();
}
}
示例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()));
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
示例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());
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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());
}