[#160] Removed unnecessary Slf4j loggers

fixes #160
This commit is contained in:
Marcin Grzejszczak
2016-02-18 11:23:09 +01:00
parent cf6f629663
commit c0620c410c
16 changed files with 69 additions and 68 deletions

View File

@@ -5,7 +5,8 @@ import java.util.concurrent.Callable;
import com.netflix.hystrix.strategy.HystrixPlugins;
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.sleuth.Span;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.cloud.sleuth.instrument.TraceKeys;
@@ -13,8 +14,7 @@ import org.springframework.cloud.sleuth.instrument.TraceKeys;
public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
private static final String HYSTRIX_COMPONENT = "hystrix";
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SleuthHystrixConcurrencyStrategy.class);
private static final Log log = LogFactory.getLog(SleuthHystrixConcurrencyStrategy.class);
private final Tracer tracer;
private final TraceKeys traceKeys;

View File

@@ -19,7 +19,10 @@ package org.springframework.cloud.sleuth.instrument.zuul;
import java.io.InputStream;
import java.net.URISyntaxException;
import org.slf4j.Logger;
import com.netflix.client.http.HttpRequest;
import com.netflix.niws.client.http.RestClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommand;
import org.springframework.cloud.netflix.zuul.filters.route.RestClientRibbonCommandFactory;
@@ -32,17 +35,13 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.util.MultiValueMap;
import com.netflix.client.http.HttpRequest;
import com.netflix.niws.client.http.RestClient;
/**
* @author Spencer Gibb
*/
public class TraceRestClientRibbonCommandFactory extends RestClientRibbonCommandFactory
implements ApplicationEventPublisherAware {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(TraceRestClientRibbonCommandFactory.class);
private static final Log log = LogFactory.getLog(TraceRestClientRibbonCommandFactory.class);
private ApplicationEventPublisher publisher;

View File

@@ -18,13 +18,14 @@ package org.springframework.cloud.sleuth.assertions;
import java.util.Objects;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.assertj.core.api.AbstractAssert;
import org.slf4j.Logger;
import org.springframework.cloud.sleuth.Span;
public class SpanAssert extends AbstractAssert<SpanAssert, Span> {
private static final Logger log = org.slf4j.LoggerFactory.getLogger(SpanAssert.class);
private static final Log log = LogFactory.getLog(SpanAssert.class);
public SpanAssert(Span actual) {
super(actual, SpanAssert.class);

View File

@@ -1,6 +1,7 @@
package org.springframework.cloud.sleuth.instrument.web.common;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.SocketUtils;
@@ -8,8 +9,7 @@ import org.springframework.util.SocketUtils;
@Configuration
public class MockServerConfiguration {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(MockServerConfiguration.class);
private static final Log log = LogFactory.getLog(MockServerConfiguration.class);
@Bean(destroyMethod = "shutdownServer")
HttpMockServer httpMockServer() {

View File

@@ -16,7 +16,8 @@
package sample;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.context.ApplicationListener;
@@ -31,8 +32,7 @@ import org.springframework.web.client.RestTemplate;
*/
@MessageEndpoint public class SampleService implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleService.class);
private static final Log log = LogFactory.getLog(SampleService.class);
@Autowired private RestTemplate restTemplate;
private int port;

View File

@@ -16,7 +16,8 @@
package sample;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
@@ -29,8 +30,7 @@ import org.springframework.messaging.Message;
@MessageEndpoint
public class SampleTransformer {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleTransformer.class);
private static final Log log = LogFactory.getLog(SampleTransformer.class);
@Autowired
SampleBackground background;

View File

@@ -19,7 +19,8 @@ package sample;
import java.util.Random;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.cloud.sleuth.Span;
@@ -37,8 +38,7 @@ import org.springframework.web.client.RestTemplate;
@RestController
public class SampleController implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleController.class);
private static final Log log = LogFactory.getLog(SampleController.class);
@Autowired
private RestTemplate restTemplate;
@@ -94,7 +94,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
Span span = this.tracer.startTrace("http:customTraceEndpoint",
new AlwaysSampler());
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));
@@ -107,7 +107,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
@RequestMapping("/start")
public String start() throws InterruptedException {
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));

View File

@@ -23,9 +23,10 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.springframework.cloud.sleuth.trace.IntegrationTestSpanContextHolder;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -48,8 +49,7 @@ import static org.assertj.core.api.BDDAssertions.then;
*/
public abstract class AbstractIntegrationTest {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(AbstractIntegrationTest.class);
private static final Log log = LogFactory.getLog(AbstractIntegrationTest.class);
protected static int pollInterval = 1;
protected static int timeout = 20;
@@ -80,9 +80,9 @@ public abstract class AbstractIntegrationTest {
protected Runnable checkServerHealth(String appName, RequestExchanger requestExchanger) {
return () -> {
ResponseEntity<String> response = requestExchanger.exchange();
log.info("Response from the [{}] health endpoint is [{}]", appName, response);
log.info(String.format("Response from the [%s] health endpoint is [%s]", appName, response));
then(response.getStatusCode()).isEqualTo(HttpStatus.OK);
log.info("[{}] is up!", appName);
log.info(String.format("[%s] is up!", appName));
};
}
@@ -92,13 +92,13 @@ public abstract class AbstractIntegrationTest {
protected ResponseEntity<String> endpointToCheckZipkinQueryHealth() {
URI uri = URI.create(getZipkinServicesQueryUrl());
log.info("Sending request to the Zipkin query service [{}]", uri);
log.info(String.format("Sending request to the Zipkin query service [%s]", uri));
return exchangeRequest(uri);
}
protected ResponseEntity<String> endpointToCheckZipkinServerHealth() {
URI uri = URI.create("http://localhost:" +getZipkinServerPort()+"/health");
log.info("Sending request to the Zipkin Server [{}]", uri);
log.info(String.format("Sending request to the Zipkin Server [%s]", uri));
return exchangeRequest(uri);
}
@@ -108,7 +108,8 @@ public abstract class AbstractIntegrationTest {
protected ResponseEntity<String> checkStateOfTheTraceId(long traceId) {
URI uri = URI.create(getZipkinTraceQueryUrl() + Long.toHexString(traceId));
log.info("Sending request to the Zipkin query service [{}]. Checking presence of trace id [{}]", uri, traceId);
log.info(String.format("Sending request to the Zipkin query service [%s]. "
+ "Checking presence of trace id [%d]", uri, traceId));
return exchangeRequest(uri);
}
@@ -137,14 +138,15 @@ public abstract class AbstractIntegrationTest {
protected Runnable allSpansWereRegisteredInZipkinWithTraceIdEqualTo(long traceId) {
return () -> {
ResponseEntity<String> response = checkStateOfTheTraceId(traceId);
log.info("Response from the Zipkin query service about the trace id [{}] for trace with id [{}]", response, traceId);
log.info(String.format("Response from the Zipkin query service about the "
+ "trace id [%s] for trace with id [%d]", response, traceId));
then(response.getStatusCode()).isEqualTo(HttpStatus.OK);
then(response.hasBody()).isTrue();
List<Span> spans = Codec.JSON.readSpans(response.getBody().getBytes());
List<String> serviceNamesNotFoundInZipkin = serviceNamesNotFoundInZipkin(spans);
List<String> spanNamesNotFoundInZipkin = annotationsNotFoundInZipkin(spans);
log.info("The following services were not found in Zipkin {}", serviceNamesNotFoundInZipkin);
log.info("The following annotations were not found in Zipkin {}", spanNamesNotFoundInZipkin);
log.info(String.format("The following services were not found in Zipkin [%s]", serviceNamesNotFoundInZipkin));
log.info(String.format("The following annotations were not found in Zipkin [%s]", spanNamesNotFoundInZipkin));
then(serviceNamesNotFoundInZipkin).isEmpty();
then(spanNamesNotFoundInZipkin).isEmpty();
log.info("Zipkin tracing is working! Sleuth is working! Let's be happy!");

View File

@@ -18,7 +18,8 @@ package tools;
import java.io.IOException;
import java.net.URI;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
@@ -35,8 +36,7 @@ import org.springframework.web.client.RestTemplate;
*/
public class AssertingRestTemplate extends RestTemplate {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(AssertingRestTemplate.class);
private static final Log log = LogFactory.getLog(AssertingRestTemplate.class);
public AssertingRestTemplate() {
setErrorHandler(new DefaultResponseErrorHandler() {

View File

@@ -18,7 +18,8 @@ package tools;
import java.net.URI;
import java.util.Random;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.sleuth.Span;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -37,8 +38,7 @@ import static org.assertj.core.api.BDDAssertions.then;
*/
public class RequestSendingRunnable implements Runnable {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(RequestSendingRunnable.class);
private static final Log log = LogFactory.getLog(RequestSendingRunnable.class);
private final RestTemplate restTemplate;
private final String url;
@@ -56,11 +56,11 @@ public class RequestSendingRunnable implements Runnable {
@Override
public void run() {
log.info("Sending the request to url [{}] with trace id in headers [{}]", this.url, this.traceId);
log.info(String.format("Sending the request to url [%s] with trace id in headers [%d]", this.url, this.traceId));
ResponseEntity<String> responseEntity =
this.restTemplate.exchange(requestWithTraceId(), String.class);
then(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
log.info("Received the following response [{}]", responseEntity);
log.info(String.format("Received the following response [%s]", responseEntity));
}
private RequestEntity<Void> requestWithTraceId() {

View File

@@ -1,7 +1,7 @@
package sample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Controller;
@Controller
public class GreetingController {
private static Logger log = LoggerFactory.getLogger(GreetingController.class);
private static final Log log = LogFactory.getLog(GreetingController.class);
@MessageMapping("/hello")
@SendTo("/topic/greetings")

View File

@@ -19,7 +19,8 @@ package sample;
import java.util.Random;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.cloud.sleuth.Span;
@@ -38,8 +39,7 @@ import org.springframework.web.client.RestTemplate;
public class SampleController implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleController.class);
private static final Log log = LogFactory.getLog(SampleController.class);
@Autowired
private RestTemplate restTemplate;
@@ -97,7 +97,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
Span span = this.tracer.startTrace("http:customTraceEndpoint",
new AlwaysSampler());
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));
@@ -110,7 +110,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
@RequestMapping("/start")
public String start() throws InterruptedException {
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));

View File

@@ -16,7 +16,8 @@
package sample;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -33,8 +34,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@EnableAsync
public class SampleZipkinApplication {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleZipkinApplication.class);
private static final Log log = LogFactory.getLog(SampleZipkinApplication.class);
public static void main(String[] args) {
SpringApplication.run(SampleZipkinApplication.class, args);
@@ -47,7 +47,7 @@ public class SampleZipkinApplication {
return new ZipkinSpanReporter() {
@Override
public void report(zipkin.Span span) {
log.info("Reporting span [{}]", span);
log.info(String.format("Reporting span [%s]", span));
}
};
}

View File

@@ -17,10 +17,11 @@ package integration;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -76,8 +77,7 @@ public class ZipkinTests extends AbstractIntegrationTest {
@Configuration
public static class WaitUntilZipkinIsUpConfig {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(WaitUntilZipkinIsUpConfig.class);
private static final Log log = LogFactory.getLog(WaitUntilZipkinIsUpConfig.class);
@Bean
public ZipkinSpanReporter spanCollector(final ZipkinProperties zipkin,

View File

@@ -19,7 +19,8 @@ package sample;
import java.util.Random;
import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.cloud.sleuth.Span;
@@ -37,8 +38,7 @@ import org.springframework.web.client.RestTemplate;
@RestController
public class SampleController implements
ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(SampleController.class);
private static final Log log = LogFactory.getLog(SampleController.class);
@Autowired
private RestTemplate restTemplate;
@Autowired
@@ -93,7 +93,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
Span span = this.tracer.startTrace("http:customTraceEndpoint",
new AlwaysSampler());
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));
@@ -106,7 +106,7 @@ ApplicationListener<EmbeddedServletContainerInitializedEvent> {
@RequestMapping("/start")
public String start() throws InterruptedException {
int millis = this.random.nextInt(1000);
log.info("Sleeping for {} millis", millis);
log.info(String.format("Sleeping for [%d] millis", millis));
Thread.sleep(millis);
this.tracer.addTag("random-sleep-millis", String.valueOf(millis));

View File

@@ -1,7 +1,7 @@
package org.springframework.cloud.sleuth.zipkin;
import org.slf4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import zipkin.Endpoint;
/**
@@ -10,8 +10,7 @@ import zipkin.Endpoint;
*/
public class FallbackHavingEndpointLocator implements EndpointLocator {
private static final Logger log = org.slf4j.LoggerFactory
.getLogger(FallbackHavingEndpointLocator.class);
private static final Log log = LogFactory.getLog(FallbackHavingEndpointLocator.class);
private final DiscoveryClientEndpointLocator discoveryClientEndpointLocator;
private final ServerPropertiesEndpointLocator serverPropertiesEndpointLocator;