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


Java LoggingConfigurator类代码示例

本文整理汇总了Java中com.spotify.logging.LoggingConfigurator的典型用法代码示例。如果您正苦于以下问题:Java LoggingConfigurator类的具体用法?Java LoggingConfigurator怎么用?Java LoggingConfigurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: start

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
@Override
public void start() {
  Preconditions.checkState(serviceName != null, "serviceName must be configured");

  // set up some defaults
  setFacility("LOCAL0");

  // our internal syslog-ng configuration splits logs up based on service name, and expects the
  // format below.
  String serviceAndPid = String.format("%s[%s]", serviceName, getMyPid());
  setSuffixPattern(serviceAndPid + ": %msg");
  setStackTracePattern(serviceAndPid + ": " + CoreConstants.TAB);

  if (getSyslogHost() == null) {
    setSyslogHost(System.getenv(LoggingConfigurator.SPOTIFY_SYSLOG_HOST));
  }
  checkSetPort(System.getenv(LoggingConfigurator.SPOTIFY_SYSLOG_PORT));

  super.start();
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:21,代码来源:SpotifyInternalAppender.java

示例2: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) {

    LoggingConfigurator.configureSyslogDefaults("example");

    while (true) {
      // Should not be logged
      logger.trace("trace!");

      // Should show up in syslog
      logger.debug("debug!");
      logger.info("info!");
      logger.warn("warn!");
      logger.error("error!", new Exception("failure"));

      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignore) {
      }
    }
  }
 
开发者ID:spotify,项目名称:logging-java,代码行数:21,代码来源:SimpleSyslogExample.java

示例3: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) {

    LoggingConfigurator.configureDefaults("example", INFO);

    while (true) {
      // Should not be logged
      logger.trace("trace!");

      // Should show up in console
      logger.debug("debug!");
      logger.info("info!");
      logger.warn("warn!");
      logger.error("error!", new Exception("failure"));

      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignore) {
      }
    }
  }
 
开发者ID:spotify,项目名称:logging-java,代码行数:21,代码来源:SimpleConsoleExample.java

示例4: checkSetPort

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
private void checkSetPort(String environmentValue) {
  if (environmentValue == null || portConfigured) {
    return;
  }

  try {
    setPort(Integer.parseInt(environmentValue));
  } catch (NumberFormatException e) {
    throw new IllegalArgumentException(
        "unable to parse value for \"" + LoggingConfigurator.SPOTIFY_SYSLOG_PORT + "\" (" +
        environmentValue + ") as an int", e);
  }
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:14,代码来源:SpotifyInternalAppender.java

示例5: shouldUseEnvironmentVariableForPortByDefault

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
@Test
public void shouldUseEnvironmentVariableForPortByDefault() throws Exception {
  environmentVariables.set(LoggingConfigurator.SPOTIFY_SYSLOG_PORT, "7642");

  appender.start();

  assertThat(appender.getPort(), is(7642));
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:9,代码来源:SpotifyInternalAppenderTest.java

示例6: shouldFailForNonIntPort

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
@Test
public void shouldFailForNonIntPort() throws Exception {
  environmentVariables.set(LoggingConfigurator.SPOTIFY_SYSLOG_PORT, "76424356436234623462345");

  thrown.expect(IllegalArgumentException.class);
  appender.start();
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:8,代码来源:SpotifyInternalAppenderTest.java

示例7: shouldSupportOverridingPort

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
@Test
public void shouldSupportOverridingPort() throws Exception {
  environmentVariables.set(LoggingConfigurator.SPOTIFY_SYSLOG_PORT, "7642");
  appender.setPort(9878);

  appender.start();

  assertThat(appender.getPort(), is(9878));
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:10,代码来源:SpotifyInternalAppenderTest.java

示例8: shouldSupportOverridingPortTo514

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
@Test
public void shouldSupportOverridingPortTo514() throws Exception {
  environmentVariables.set(LoggingConfigurator.SPOTIFY_SYSLOG_PORT, "7642");
  appender.setPort(514);

  appender.start();

  assertThat(appender.getPort(), is(514));
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:10,代码来源:SpotifyInternalAppenderTest.java

示例9: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) throws IOException, ExecutionException, InterruptedException {

    final String project = Util.defaultProject();

    GoogleCredential credential;

    // Use credentials from file if available
    try {
      credential = GoogleCredential
          .fromStream(new FileInputStream("credentials.json"))
          .createScoped(PubsubScopes.all());
    } catch (IOException e) {
      credential = GoogleCredential.getApplicationDefault()
          .createScoped(PubsubScopes.all());
    }

    LoggingConfigurator.configureDefaults("benchmark", WARN);

    final String subscription = System.getenv("GOOGLE_PUBSUB_SUBSCRIPTION");
    if (subscription == null) {
      System.err.println("Please specify a subscription using the GOOGLE_PUBSUB_SUBSCRIPTION environment variable.");
      System.exit(1);
    }

    System.out.println("Consuming from GOOGLE_PUBSUB_SUBSCRIPTION='" + subscription + "'");

    final Pubsub pubsub = new Pubsub.Builder(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(), credential)
        .setApplicationName("pull-benchmark")
        .build();

    final Pubsub.Projects.Subscriptions subscriptions = pubsub.projects().subscriptions();

    final String canonicalSubscription = Subscription.canonicalSubscription(project, subscription);

    final ProgressMeter meter = new ProgressMeter();
    final ProgressMeter.Metric receives = meter.group("operations").metric("receives", "messages");

    final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());

    // Pull concurrently
    for (int i = 0; i < PULLER_CONCURRENCY; i++) {
      pull(subscriptions, canonicalSubscription, receives, executor);
    }
  }
 
开发者ID:spotify,项目名称:async-google-pubsub-client,代码行数:45,代码来源:GoogleClientPullBenchmark.java

示例10: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) throws IOException {

    final String project = Util.defaultProject();

    GoogleCredential credential;

    // Use credentials from file if available
    try {
      credential = GoogleCredential
          .fromStream(new FileInputStream("credentials.json"))
          .createScoped(PubsubScopes.all());
    } catch (IOException e) {
      credential = GoogleCredential.getApplicationDefault()
          .createScoped(PubsubScopes.all());
    }

    final Pubsub pubsub = Pubsub.builder()
        .credential(credential)
        .compressionLevel(Deflater.BEST_SPEED)
        .enabledCipherSuites(nonGcmCiphers())
        .build();

    final Publisher publisher = Publisher.builder()
        .pubsub(pubsub)
        .concurrency(128)
        .project(project)
        .build();

    LoggingConfigurator.configureDefaults("benchmark", WARN);

    final String topicPrefix = TEST_NAME_PREFIX + ThreadLocalRandom.current().nextInt();

    final List<String> topics = IntStream.range(0, 100)
        .mapToObj(i -> topicPrefix + "-" + i)
        .collect(toList());

    topics.stream()
        .map(topic -> pubsub.createTopic(project, topic))
        .collect(toList())
        .forEach(Futures::getUnchecked);

    final List<Message> messages = IntStream.range(0, 1000)
        .mapToObj(i -> {
          final StringBuilder s = new StringBuilder();
          while (s.length() < MESSAGE_SIZE) {
            s.append(ThreadLocalRandom.current().nextInt());
          }
          return Message.ofEncoded(s.toString());
        })
        .collect(toList());

    final ProgressMeter meter = new ProgressMeter();
    final ProgressMeter.Metric requests = meter.group("operations").metric("publishes", "messages");

    for (int i = 0; i < 100000; i++) {
      benchSend(publisher, messages, topics, requests);
    }
  }
 
开发者ID:spotify,项目名称:async-google-pubsub-client,代码行数:59,代码来源:PublisherBenchmark.java

示例11: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) throws IOException, ExecutionException, InterruptedException {

    final String project = Util.defaultProject();

    GoogleCredential credential;

    // Use credentials from file if available
    try {
      credential = GoogleCredential
          .fromStream(new FileInputStream("credentials.json"))
          .createScoped(PubsubScopes.all());
    } catch (IOException e) {
      credential = GoogleCredential.getApplicationDefault()
          .createScoped(PubsubScopes.all());
    }

    final Pubsub pubsub = Pubsub.builder()
        .credential(credential)
        .compressionLevel(Deflater.BEST_SPEED)
        .enabledCipherSuites(nonGcmCiphers())
        .build();

    final Publisher publisher = Publisher.builder()
        .pubsub(pubsub)
        .concurrency(PUBLISHER_CONCURRENCY)
        .project(project)
        .build();

    LoggingConfigurator.configureDefaults("benchmark", WARN);

    final String topic = "test-" + Long.toHexString(ThreadLocalRandom.current().nextLong());
    final String subscription = "test-" + Long.toHexString(ThreadLocalRandom.current().nextLong());

    pubsub.createTopic(project, topic).get();
    pubsub.createSubscription(project, subscription, topic).get();

    final List<String> payloads = IntStream.range(0, 1024)
        .mapToObj(i -> {
          final StringBuilder s = new StringBuilder();
          while (s.length() < MESSAGE_SIZE) {
            s.append(ThreadLocalRandom.current().nextInt());
          }
          return Message.encode(s.toString());
        })
        .collect(toList());
    final int payloadIxMask = 1024 - 1;

    final Supplier<Message> generator = () -> Message.builder()
        .data(payloads.get(ThreadLocalRandom.current().nextInt() & payloadIxMask))
        .putAttribute("ts", Long.toHexString(System.nanoTime()))
        .build();

    final ProgressMeter meter = new ProgressMeter();
    final ProgressMeter.Metric publishes = meter.group("operations").metric("publishes", "messages");
    final ProgressMeter.Metric receives = meter.group("operations").metric("receives", "messages");

    for (int i = 0; i < 100000; i++) {
      publish(publisher, generator, topic, publishes);
    }

    // Pull concurrently and (asynchronously) publish a new message for every message received
    for (int i = 0; i < PULLER_CONCURRENCY; i++) {
      pull(project, pubsub, subscription, receives, () -> publish(publisher, generator, topic, publishes));
    }
  }
 
开发者ID:spotify,项目名称:async-google-pubsub-client,代码行数:66,代码来源:EndToEndBenchmark.java

示例12: main

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
public static void main(final String... args) throws IOException, ExecutionException, InterruptedException {

    final String project = Util.defaultProject();

    GoogleCredential credential;

    // Use credentials from file if available
    try {
      credential = GoogleCredential
          .fromStream(new FileInputStream("credentials.json"))
          .createScoped(PubsubScopes.all());
    } catch (IOException e) {
      credential = GoogleCredential.getApplicationDefault()
          .createScoped(PubsubScopes.all());
    }

    final Pubsub pubsub = Pubsub.builder()
        .credential(credential)
        .compressionLevel(Deflater.BEST_SPEED)
        .enabledCipherSuites(Util.nonGcmCiphers())
        .build();

    LoggingConfigurator.configureDefaults("benchmark", WARN);

    final String subscription = System.getenv("GOOGLE_PUBSUB_SUBSCRIPTION");
    if (subscription == null) {
      System.err.println("Please specify a subscription using the GOOGLE_PUBSUB_SUBSCRIPTION environment variable.");
      System.exit(1);
    }

    System.out.println("Consuming from GOOGLE_PUBSUB_SUBSCRIPTION='" + subscription + "'");

    final ProgressMeter meter = new ProgressMeter();
    final ProgressMeter.Metric receives = meter.group("operations").metric("receives", "messages");

    final Puller puller = Puller.builder()
        .pubsub(pubsub)
        .batchSize(1000)
        .concurrency(PULLER_CONCURRENCY)
        .project(project)
        .subscription(subscription)
        .messageHandler(new Handler(receives))
        .build();

    while (true) {
      Thread.sleep(1000);
      System.out.println("outstanding messages: " + puller.outstandingMessages());
      System.out.println("outstanding requests: " + puller.outstandingRequests());
    }
  }
 
开发者ID:spotify,项目名称:async-google-pubsub-client,代码行数:51,代码来源:PullerBenchmark.java

示例13: setSyslogHostEnvVar

import com.spotify.logging.LoggingConfigurator; //导入依赖的package包/类
private void setSyslogHostEnvVar() {
  // this must be a valid host name that can be looked up anywhere
  environmentVariables.set(LoggingConfigurator.SPOTIFY_SYSLOG_HOST, "www.spotify.com");
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:5,代码来源:SpotifyInternalAppenderTest.java


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