org.vertx.java.core.logging.Logger类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(199)

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

Logger介绍

[英]This class allows us to isolate all our logging dependencies in one place. It also allows us to have zero runtime 3rd party logging jar dependencies, since we default to JUL by default.

By default logging will occur using JUL (Java-Util-Logging). The logging configuration file (logging.properties) used by JUL will taken from the default logging.properties in the JDK installation if no java.util.logging.config.file system property is set. The vertx-java / vertx-ruby / etc scripts set java.util.logging.config.file to point at the logging.properties in the vertx distro install directory. This in turn configures vertx to log to a file in a directory called vertx-logs in the users home directory.

If you would prefer to use Log4J or SLF4J instead of JUL then you can set a system property called org.vertx.logger-delegate-factory-class-name to the class name of the delegate for your logging system. For Log4J the value is org.vertx.java.core.logging.Log4JLogDelegateFactory, for SLF4J the value is org.vertx.java.core.logging.SLF4JLogDelegateFactory. You will need to ensure whatever jar files required by your favourite log framework are on your classpath.
[中]这个类允许我们在一个地方隔离所有日志依赖项。它还允许我们没有运行时第三方日志jar依赖项,因为我们默认为JUL。
默认情况下,将使用JUL(JavautilLogging)进行日志记录。JUL使用的日志配置文件(logging.properties)将取自默认日志。如果没有java,则JDK安装中的属性。util。登录中。配置。已设置文件系统属性。VertxJava/VertxRuby/etc脚本设置java。util。登录中。配置。文件指向日志记录。vertx发行版安装目录中的属性。这又将vertx配置为登录到用户主目录中名为vertx logs的目录中的文件。
如果您希望使用Log4J或SLF4J而不是JUL,那么您可以设置一个名为org的系统属性。维特斯。logger delegate factory类名为您的日志记录系统的代理的类名。对于Log4J,值为org。维特斯。JAVA果心登录中。Log4JLogDelegateFactory,对于SLF4J,值为org。维特斯。JAVA果心登录中。SLF4JLogDelegateFactory。您需要确保您喜爱的日志框架所需的任何jar文件都位于类路径上。

代码示例

代码示例来源:origin: io.vertx/vertx-platform

private void deployHADeployments() {
 int size = toDeployOnQuorum.size();
 if (size != 0) {
  log.info("There are " + size + " HA deployments waiting on a quorum. These will now be deployed");
  Runnable task;
  while ((task = toDeployOnQuorum.poll()) != null) {
   try {
    task.run();
   } catch (Throwable t) {
    log.error("Failed to run redeployment task", t);
   }
  }
 }
}

代码示例来源:origin: org.vert-x/vertx-core

public void handle(AsyncResult<Boolean> res) {
  if (res.succeeded()) {
   if (res.result) {
    cacheAuthorisation(sessionID, sock);
    checkAndSend(send, address, jsonObject, sock, replyAddress);
   } else {
    log.debug("Inbound message for address " + address + " rejected because sessionID is not authorised");
   }
  } else {
   log.error("Error in performing authorisation", res.exception);
  }
 }
});

代码示例来源:origin: org.vert-x/vertx-core

public void handle(HttpServerRequest req) {
  if (log.isTraceEnabled()) log.trace("Request: " + req.uri + " does not match, returning 404");
  req.response.statusCode = 404;
  req.response.end();
 }
});

代码示例来源:origin: org.vert-x/vertx-core

private void logInternal(final String perms) {
  if ((perms != null) && log.isDebugEnabled()) {
    log.debug("You are running on Windows and POSIX style file permissions are not supported");
  }
}

代码示例来源:origin: com.englishtown/vertx-mod-hk2

@Override
public void reportException(Logger logger, Throwable t) {
  if (logger != null) {
    logger.error("Exception in HK2VerticleFactory", t);
  }
}

代码示例来源:origin: org.vert-x/vertx-platform

log.warn("Overflow event on watched directory");
continue;
   registerAll(moduleDir, child);
  } catch (IOException e) {
   log.error("Failed to register child", e);
   throw new IllegalStateException(e.getMessage());

代码示例来源:origin: io.vertx/vertx-testframework

@Test
protected void runTestInLoop(String testName, int iters) throws Exception {
 Method meth = getClass().getMethod(testName, (Class<?>[])null);
 for (int i = 0; i < iters; i++) {
  log.info("****************************** ITER " + i);
  meth.invoke(this);
  tearDown();
  if (i != iters - 1) {
   setUp();
  }
 }
}

代码示例来源:origin: io.vertx/vertx-platform

private void unzipModule(final ModuleIdentifier modID, final ModuleZipInfo zipInfo, boolean deleteZip) {
 // We synchronize to prevent a race whereby it tries to unzip the same module at the
 // same time (e.g. deployModule for the same module name has been called in parallel)
 String modName = modID.toString();
 synchronized (modName.intern()) {
  checkCreateModDirs();
  File fdest = new File(modRoot, modName);
  File sdest = new File(systemModRoot, modName);
  if (fdest.exists() || sdest.exists()) {
   // This can happen if the same module is requested to be installed
   // at around the same time
   // It's ok if this happens
   log.warn("Module " + modID + " is already installed");
   return;
  }
  // Unzip into temp dir first
  File tdest = unzipIntoTmpDir(zipInfo, deleteZip);
  // Check if it's a system module
  JsonObject conf = loadModuleConfig(createModJSONFile(tdest), modID);
  ModuleFields fields = new ModuleFields(conf);
  boolean system = fields.isSystem();
  // Now copy it to the proper directory
  String moveFrom = tdest.getAbsolutePath();
  safeMove(moveFrom, system ? sdest.getAbsolutePath() : fdest.getAbsolutePath());
  log.info("Module " + modID +" successfully installed");
 }
}

代码示例来源:origin: org.vert-x/vertx-core

public void handle(HttpServerRequest req) {
  try {
   if (log.isTraceEnabled()) log.trace("In Iframe handler");
   if (etag != null && etag.equals(req.headers().get("if-none-match"))) {
    req.response.statusCode = 304;
    req.response.end();
   } else {
    req.response.headers().put("Content-Type", "text/html; charset=UTF-8");
    req.response.headers().put("Cache-Control", "public,max-age=31536000");
    long oneYear = 365 * 24 * 60 * 60 * 1000;
    String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYear));
    req.response.headers().put("Expires", expires);
    req.response.headers().put("ETag", etag);
    req.response.end(iframeHTML);
   }
  } catch (Exception e) {
   log.error("Failed to server iframe", e);
  }
 }
};

代码示例来源:origin: org.vert-x/vertx-core

public void handle(final Message<JsonObject> msg) {
  Match curMatch = checkMatches(false, address, msg.body);
  if (curMatch.doesMatch) {
   if (curMatch.requiresAuth && sockAuths.get(sock) == null) {
    log.debug("Outbound message for address " + address + " rejected because auth is required and socket is not authed");
   } else {
    checkAddAccceptedReplyAddress(msg.replyAddress);
    deliverMessage(sock, address, msg);
   }
  } else {
   log.debug("Outbound message for address " + address + " rejected because there is no inbound match");
  }
 }
};

代码示例来源:origin: org.vert-x/vertx-platform

public synchronized void close() {
 vertx.cancelTimer(timerID);
 Set<Deployment>  deps = new HashSet<>();
 for (Map.Entry<Path, Set<Deployment>> entry: watchedDeployments.entrySet()) {
  deps.addAll(entry.getValue());
 }
 toUndeploy.addAll(deps);
 processUndeployments();
 try {
     watchService.close();
   } catch (IOException ex) {
     log.warn("Error while shutting down watch service: " + ex.getMessage(), ex);
   }
 closed = true;
}

代码示例来源:origin: org.vert-x/vertx-core

public synchronized void report() {
 log.trace("available: " + available.size() + " connection count: " + connectionCount + " waiters: " + waiters.size());
}

代码示例来源:origin: org.vert-x/vertx-core

public void handle(AsyncResult<Void> event) {
  if (event.exception != null) {
   log.error("Failed to remove entry", event.exception);
  }
 }
};

代码示例来源:origin: org.vert-x/vertx-platform

is = getClass().getClassLoader().getResourceAsStream("langs.properties");
 if (is == null) {
  log.warn("No language mappings found!");
 } else {
  Properties props = new Properties();
 log.error("Failed to load langs.properties: " + e.getMessage());
} finally {
 if (is != null) {

代码示例来源:origin: io.vertx/vertx-platform

private void fatJar(String modName, Args args) {
 log.info("Attempting to make a fat jar for module " + modName);
 String directory = args.map.get("-d");
 if (directory != null && !new File(directory).exists()) {
  log.info("Directory does not exist: " + directory);
  return;
 }
 createPM().makeFatJar(modName, directory, createLoggingHandler("making fat jar", unblockHandler()));
 block();
}

代码示例来源:origin: io.vertx/vertx-platform

if (valid) {
 for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
  log.info(d);
  log.warn(d);

代码示例来源:origin: com.englishtown/vertx-mod-cassandra

@Override
protected void initSeeds(JsonArray seeds) {
  // Recall super
  super.initSeeds(seeds);
  // If default, try env vars
  if (DEFAULT_SEEDS.equals(this.seeds)) {
    String envVarSeeds = container.env().get(ENV_VAR_SEEDS);
    if (!Strings.isNullOrEmpty(envVarSeeds)) {
      logger.debug("Using environment configuration of " + envVarSeeds);
      String[] seedsArray = envVarSeeds.split("\\|");
      this.seeds = ImmutableList.copyOf(seedsArray);
    }
  }
}

代码示例来源:origin: org.vert-x/vertx-core

private void checkAndSend(boolean send, final String address, JsonObject jsonObject,
             final SockJSSocket sock,
             final String replyAddress) {
 final Handler<Message<JsonObject>> replyHandler;
 if (replyAddress != null) {
  replyHandler = new Handler<Message<JsonObject>>() {
   public void handle(Message<JsonObject> message) {
    // Note we don't check outbound matches for replies
    // Replies are always let through if the original message
    // was approved
    checkAddAccceptedReplyAddress(message.replyAddress);
    deliverMessage(sock, replyAddress, message);
   }
  };
 } else {
  replyHandler = null;
 }
 if (log.isDebugEnabled()) {
  log.debug("Forwarding message to address " + address + " on event bus");
 }
 if (send) {
  eb.send(address, jsonObject, replyHandler);
 } else {
  eb.publish(address, jsonObject);
 }
}

代码示例来源:origin: org.vert-x/vertx-core

/**
 * Create the singleton Hazelcast instance if necessary
 * @return
 */
private synchronized HazelcastInstance initHazelcast() {
 if (instance == null) {
  Config cfg = getConfig(null);
  if (cfg == null) {
   log.warn("Cannot find cluster.xml on classpath. Using default cluster configuration");
  }
  // default instance
  instance = Hazelcast.init(cfg);
  // Properly shutdown all instances
  Runtime.getRuntime().addShutdownHook(new Thread() {
   @Override
   public void run() {
    Hazelcast.shutdownAll();
   }
  });
 }
 return instance;
}

代码示例来源:origin: org.vert-x/vertx-platform

public void handle(HttpClientResponse resp) {
  if (resp.statusCode == 200) {
   log.info("Downloading module...");
   resp.bodyHandler(new Handler<Buffer>() {
    public void handle(Buffer buffer) {
     mod.set(buffer);
     latch.countDown();
    }
   });
  } else if (resp.statusCode == 404) {
   log.error("Can't find module " + moduleName + " in repository");
   latch.countDown();
  } else {
   log.error("Failed to download module: " + resp.statusCode);
   latch.countDown();
  }
 }
});

相关文章

微信公众号

最新文章

更多