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


Java Slf4jLogger类代码示例

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


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

示例1: getInstance

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint
 * 		URL of Marathon
 * @param interceptors optional request interceptors
 * @return Marathon client
 */
public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {

	Builder b = Feign.builder()
			.encoder(new GsonEncoder(ModelUtils.GSON))
			.decoder(new GsonDecoder(ModelUtils.GSON))
			.errorDecoder(new MarathonErrorDecoder());
	if (interceptors != null)
		b.requestInterceptors(asList(interceptors));
	String debugOutput = System.getenv(DEBUG_JSON_OUTPUT);
	if ("System.out".equals(debugOutput)) {
		System.setProperty("org.slf4j.simpleLogger.logFile", "System.out");
		System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug");
		b.logger(new Slf4jLogger()).logLevel(Logger.Level.FULL);
	} else if (debugOutput != null) {
		b.logger(new Logger.JavaLogger().appendToFile(debugOutput)).logLevel(Logger.Level.FULL);
	}
	b.requestInterceptor(new MarathonHeadersInterceptor());
	return b.target(Marathon.class, endpoint);
}
 
开发者ID:mesosphere,项目名称:marathon-client,代码行数:29,代码来源:MarathonClient.java

示例2: connect

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
static Retz connect(
        URI uri,
        Authenticator authenticator,
        SSLSocketFactory socketFactory,
        HostnameVerifier hostnameVerifier) {
    String url = Objects.requireNonNull(uri, "uri cannot be null").toString();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new Jdk8Module());
    return Feign.builder()
            .client(new Client.Default(socketFactory, hostnameVerifier))
            .logger(new Slf4jLogger())
            .encoder(new JacksonEncoder(mapper))
            .decoder(new JacksonDecoder(mapper))
            .errorDecoder(new ErrorResponseDecoder(mapper))
            .requestInterceptor(new AuthHeaderInterceptor(authenticator))
            .target(Retz.class, url);
}
 
开发者ID:retz,项目名称:retz,代码行数:18,代码来源:Retz.java

示例3: testRequestOptions

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * Test the Feign Request Options version of the Vert.x Feign Client.
 * This proves regression is not broken for existing use-cases.
 * @param context Test Context
 */
@Test
public void testRequestOptions(TestContext context) {
  IcecreamServiceApi client = VertxFeign
          .builder()
          .vertx(vertx)
          .options(new Request.Options(5000,5000) ) // Plain old Feign Request.Options (regression)
          .decoder(new JacksonDecoder(TestUtils.MAPPER))
          .logger(new Slf4jLogger())
          .logLevel(Logger.Level.FULL)
          .target(IcecreamServiceApi.class, "http://localhost:8089");

  stubFor(get(urlEqualTo("/icecream/flavors"))
          .withHeader("Accept", equalTo("application/json"))
          .withHeader("Accept-Encoding", absent()) // Test that Accept-Encoding is missing (since we're using Request.Options)
          .willReturn(aResponse()
                  .withStatus(200)
                  .withHeader("Content-Type", "application/json")
                  .withBody(flavorsStr)));

  testClient(client, context);
}
 
开发者ID:OpenFeign,项目名称:feign-vertx,代码行数:27,代码来源:VertxHttpOptionsTest.java

示例4: BackendServiceFactory

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
@Inject
public BackendServiceFactory(InjectionManager serviceLocator) {
	awsLambdaClient = new AWSLambdaClient();
	awsLambdaClient.configureRegion(BACKEND_SERVICE_REGION);
	backendService = Feign.builder()
			.client(FeignLambdaServiceInvokerClient.builder()
					.setRegion(BACKEND_SERVICE_REGION)
					.setFunctionName(BACKEND_SERVICE_FUNCTION_NAME)
					.build())
			.decoder(new JacksonDecoder())
			.encoder(new JacksonEncoder())
			.logger(new Slf4jLogger())
			.target(new LambdaServiceFunctionTarget<BackendService>(BackendService.class) {
				@Override
				public Request apply(RequestTemplate input) {
					// TODO inject the context directly => requires the context to be bound as proxy
					Context lambdaContext = serviceLocator.getInstance(Context.class);
					// propagate the AWS request ID => the called service can log the original AWS request ID
					input.header("X-Base-Aws-Request-Id", lambdaContext.getAwsRequestId());
					return super.apply(input);
				}
			});
}
 
开发者ID:bbilger,项目名称:jrestless-examples,代码行数:24,代码来源:BackendServiceFactory.java

示例5: StoreClient

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
public StoreClient(RequestInterceptor requestInterceptor) {

        Feign.Builder builder = Feign.builder().client(
                org.wso2.carbon.apimgt.integration.client.util.Utils.getSSLClient()).logger(new Slf4jLogger())
                .logLevel(Logger.Level.FULL)
                .requestInterceptor(requestInterceptor).encoder(new GsonEncoder()).decoder(new GsonDecoder());
        String basePath = Utils.replaceSystemProperty(APIMConfigReader.getInstance().getConfig().getStoreEndpoint());

        apis = builder.target(APICollectionApi.class, basePath);
        individualApi = builder.target(APIIndividualApi.class, basePath);
        applications = builder.target(ApplicationCollectionApi.class, basePath);
        individualApplication = builder.target(ApplicationIndividualApi.class, basePath);
        subscriptions = builder.target(SubscriptionCollectionApi.class, basePath);
        individualSubscription = builder.target(SubscriptionIndividualApi.class, basePath);
        subscriptionMultitpleApi = builder.target(SubscriptionMultitpleApi.class, basePath);
        tags = builder.target(TagCollectionApi.class, basePath);
        individualTier = builder.target(ThrottlingTierIndividualApi.class, basePath);
        tiers = builder.retryer(new Retryer.Default(100L, TimeUnit.SECONDS.toMillis(1L), 1))
                .options(new Request.Options(10000, 5000))
                .target(ThrottlingTierCollectionApi.class, basePath);

    }
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:23,代码来源:StoreClient.java

示例6: build

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * Generate a new Marathon client.
 * 
 * @param marathonProperties
 *          the properties containing the client information
 * @return the new client
 */
@Override
public Marathon build(MarathonProperties marathonProperties) {
  LOG.info("Generating Marathon client with parameters: {}", marathonProperties);

  return Feign
      .builder()
      .encoder(new GsonEncoder(ModelUtils.GSON))
      .decoder(new GsonDecoder(ModelUtils.GSON))
      .logger(new Slf4jLogger(Marathon.class))
      .logLevel(Level.FULL)
      .errorDecoder(new DeserializingMarathonErrorDecoder())
      .requestInterceptor(new BasicAuthRequestInterceptor(
          marathonProperties.getUsername(), marathonProperties.getPassword()))
      .requestInterceptor(template -> {
        template.header(HttpHeaders.ACCEPT, "application/json");
        template.header(HttpHeaders.CONTENT_TYPE, "application/json");
      })
      .target(Marathon.class, marathonProperties.getUrl().toString());
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:27,代码来源:MarathonClientFactory.java

示例7: simpleFeignBuilder

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
public static HystrixFeign.Builder simpleFeignBuilder() {
    JacksonDecoder decoder = new JacksonDecoder(defaultObjectMapper);
    return HystrixFeign.builder()
            .setterFactory(new DefaultSetterFactory())
            .logger(new Slf4jLogger())
            .logLevel(Logger.Level.FULL)
            .retryer(new Retryer.Default())
            .contract(new Contract.Default())
            .client(new OkHttpClient())
            .options(new Request.Options())
            .encoder(new JacksonEncoder(defaultObjectMapper))
            .decoder(decoder)
            .errorDecoder(new AccessApiErrorDecoder(decoder));
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:15,代码来源:Clients.java

示例8: connect

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * Constructs ready-to use client
 *
 * @param uri base uri
 * @return instance of api class
 */
static TicketApi connect(String uri) {
    ObjectMapper mapper = new ObjectMapper()
            .disable(FAIL_ON_UNKNOWN_PROPERTIES);

    return Feign.builder()
            .decoder(new JacksonDecoder(mapper))
            .encoder(new JacksonEncoder(mapper))
            .logger(new Slf4jLogger(TicketApi.class))
            .logLevel(Logger.Level.FULL)
            .target(TicketApi.class, uri);
}
 
开发者ID:lanwen,项目名称:wiremock-junit5,代码行数:18,代码来源:TicketApi.java

示例9: Client

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
private Client(
    final String host,
    final feign.Client client,
    final feign.Logger.Level logLevel,
    final RequestInterceptor requestInterceptor,
    final Retryer retryer,
    final Request.Options options
) {
    final MetacatJsonLocator metacatJsonLocator = new MetacatJsonLocator();
    final ObjectMapper mapper = metacatJsonLocator
        .getPrettyObjectMapper()
        .copy()
        .registerModule(new GuavaModule())
        .registerModule(new JaxbAnnotationModule());

    log.info("Connecting to {}", host);
    this.host = host;

    feignBuilder = Feign.builder()
        .client(client)
        .logger(new Slf4jLogger())
        .logLevel(logLevel)
        .contract(new JAXRSContract())
        .encoder(new JacksonEncoder(mapper))
        .decoder(new JacksonDecoder(mapper))
        .errorDecoder(new MetacatErrorDecoder(metacatJsonLocator))
        .requestInterceptor(requestInterceptor)
        .retryer(retryer)
        .options(options);

    api = getApiClient(MetacatV1.class);
    partitionApi = getApiClient(PartitionV1.class);
    metadataApi = getApiClient(MetadataV1.class);
    resolverApi = getApiClient(ResolverV1.class);
    tagApi = getApiClient(TagV1.class);
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:37,代码来源:Client.java

示例10: getInstance

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint URL of Marathon
 */
public static Marathon getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder()
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .logger(new Slf4jLogger())
            .decoder(new GsonDecoder(ModelUtils.GSON))
            .errorDecoder(new MarathonErrorDecoder());
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MarathonHeadersInterceptor());
    return b.target(Marathon.class, endpoint);
}
 
开发者ID:wso2,项目名称:mesos-artifacts,代码行数:19,代码来源:MesosMarathonClient.java

示例11: getInstance

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * The generalized version of the method that allows more in-depth customizations via
 * {@link RequestInterceptor}s.
 *
 * @param endpoint URL of Mesos DNS
 */
public static MesosDNS getInstance(String endpoint, RequestInterceptor... interceptors) {
    Feign.Builder b = Feign.builder()
            .encoder(new GsonEncoder(ModelUtils.GSON))
            .logger(new Slf4jLogger())
            .decoder(new GsonDecoder(ModelUtils.GSON))
            .errorDecoder(new MesosDNSErrorDecoder());
    if (interceptors != null) {
        b.requestInterceptors(asList(interceptors));
    }
    b.requestInterceptor(new MesosDNSHeadersInterceptor());
    return b.target(MesosDNS.class, endpoint);
}
 
开发者ID:wso2,项目名称:mesos-artifacts,代码行数:19,代码来源:MesosDNSClient.java

示例12: tempoApiBuilder

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
@Bean
public Feign.Builder tempoApiBuilder() {
    final ObjectMapper objectMapper = createObjectMapper();

    final JacksonDecoder decoder = new JacksonDecoder(objectMapper);
    final JacksonEncoder encoder = new JacksonEncoder(objectMapper);

    return Feign.builder()
            .requestInterceptor(tempoApiAuthentication())
            .errorDecoder(new TempoApiErrorDecoder(decoder))
            .client(new ApacheHttpClient(httpClient))
            .encoder(encoder)
            .decoder(decoder)
            .logger(new Slf4jLogger());
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:TempoApiConfiguration.java

示例13: oneSignal

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
private static OneSignalComms oneSignal() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    objectMapper.setSerializationInclusion(Include.NON_EMPTY);
    JacksonDecoder decoder = new JacksonDecoder(objectMapper);
    return Feign.builder()
            .encoder(new JacksonEncoder(objectMapper))
            .decoder(decoder)
            .decode404()
            .errorDecoder(new OneSignalErrorDecoder(decoder))
            .logger(new Slf4jLogger())
            .logLevel(Level.FULL)
            .target(OneSignalComms.class, "https://onesignal.com/api/v1");
}
 
开发者ID:CurrencyFair,项目名称:OneSignal-Java-SDK,代码行数:16,代码来源:OneSignal.java

示例14: testHttpClientOptions

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
/**
 * Test the Vert.x HttpClientOptions version of the Vert.x Feign Client.
 * This is useful for use-cases like HTTPS/2 or gzip compressed responses.
 * @param context Test Context
 */
@Test
public void testHttpClientOptions(TestContext context) {
  // NOTE: We cannot use HTTPS/2 because Wiremock 2.1.0-beta uses Jetty 9.2.13.v20150730.
  //       Jetty 9.3 is required for HTTPS/2. So we use HttpClientOptions.TryUseCompression(true)
  //       instead to verify we're using the Vert.x HttpClientOptions object.
  HttpClientOptions options = new HttpClientOptions().
          setTryUseCompression(true). // Attribute under test, not available with Feign Request.Options
          setConnectTimeout(5000).
          setIdleTimeout(5000);

  IcecreamServiceApi client = VertxFeign
          .builder()
          .vertx(vertx)
          .options(options) // New feature! Accepts HttpClientOptions
          .decoder(new JacksonDecoder(TestUtils.MAPPER))
          .logger(new Slf4jLogger())
          .logLevel(Logger.Level.FULL)
          .target(IcecreamServiceApi.class, "http://localhost:8089");

  stubFor(get(urlEqualTo("/icecream/flavors"))
          .withHeader("Accept", equalTo("application/json"))
          .withHeader("Accept-Encoding", equalTo("deflate, gzip")) // Test setTryUseCompression(true) affected the request
          .willReturn(aResponse()
                  .withStatus(200)
                  .withHeader("Content-Type", "application/json")
                  .withBody(flavorsStr)));

  testClient(client, context);
}
 
开发者ID:OpenFeign,项目名称:feign-vertx,代码行数:35,代码来源:VertxHttpOptionsTest.java

示例15: buildClient

import feign.slf4j.Slf4jLogger; //导入依赖的package包/类
private <T> T buildClient(Class<T> clientClazz, RequestInterceptor authenticationInterceptor) {
    return Feign.builder()
            .logger(new Slf4jLogger(this.getClass()))
            .logLevel(Logger.Level.FULL)
            .encoder(new GsonEncoder())
            .decoder(new GsonDecoder())
            .requestInterceptor(authenticationInterceptor)
            .target(clientClazz, "https://api.meetup.com");
}
 
开发者ID:BordeauxJUG,项目名称:bdxjug-api,代码行数:10,代码来源:MeetupFeignConfiguration.java


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