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