diff --git a/pom.xml b/pom.xml index d09049960..94c61f3f5 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.scalecube scalecube-parent - 0.2.20 + 0.3.1 scalecube-services-parent @@ -59,23 +59,22 @@ - 2.6.18.rc1 - 1.0.32 + 2.6.18.RC10 + 1.0.33.RC1 2020.0.32 - 2.15.1 + 2.18.0 4.1.93.Final 1.1.4 1.6.0 - 1.7.36 - 2.17.2 - 3.4.2 3.0.2 2.1.2 4.6.1 5.8.2 1.3 + 2.17.2 + 1.7.36 https://maven.pkg.github.com/scalecube/scalecube-services @@ -150,13 +149,6 @@ import - - - com.lmax - disruptor - ${disruptor.version} - - io.rsocket diff --git a/services-discovery/pom.xml b/services-discovery/pom.xml index 21c370316..3a4e9e69f 100644 --- a/services-discovery/pom.xml +++ b/services-discovery/pom.xml @@ -14,13 +14,11 @@ io.scalecube scalecube-cluster - io.scalecube scalecube-services-api ${project.version} - org.apache.logging.log4j @@ -32,7 +30,6 @@ log4j-core test - io.scalecube scalecube-codec-jackson diff --git a/services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java b/services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java index 4874b99ec..cb482b259 100644 --- a/services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java +++ b/services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java @@ -18,19 +18,19 @@ import io.scalecube.services.ServiceEndpoint; import io.scalecube.services.discovery.api.ServiceDiscovery; import io.scalecube.services.discovery.api.ServiceDiscoveryEvent; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.nio.ByteBuffer; import java.time.Duration; import java.util.StringJoiner; import java.util.function.UnaryOperator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.Exceptions; import reactor.core.publisher.Flux; import reactor.core.publisher.Sinks; public final class ScalecubeServiceDiscovery implements ServiceDiscovery { - private static final Logger LOGGER = LoggerFactory.getLogger(ServiceDiscovery.class); + private static final Logger LOGGER = System.getLogger(ServiceDiscovery.class.getName()); private ClusterConfig clusterConfig; private Cluster cluster; @@ -107,17 +107,18 @@ public void shutdown() { } private void onMembershipEvent(MembershipEvent membershipEvent) { - LOGGER.debug("onMembershipEvent: {}", membershipEvent); + LOGGER.log(Level.DEBUG, "onMembershipEvent: {0}", membershipEvent); ServiceDiscoveryEvent discoveryEvent = toServiceDiscoveryEvent(membershipEvent); if (discoveryEvent == null) { - LOGGER.warn( - "DiscoveryEvent is null, cannot publish it (corresponding membershipEvent: {})", + LOGGER.log( + Level.WARNING, + "DiscoveryEvent is null, cannot publish it (corresponding membershipEvent: {0})", membershipEvent); return; } - LOGGER.debug("Publish discoveryEvent: {}", discoveryEvent); + LOGGER.log(Level.DEBUG, "Publish discoveryEvent: {0}", discoveryEvent); sink.emitNext(discoveryEvent, busyLooping(Duration.ofSeconds(3))); } @@ -141,7 +142,7 @@ private ServiceEndpoint toServiceEndpoint(ByteBuffer byteBuffer) { try { return (ServiceEndpoint) clusterConfig.metadataCodec().deserialize(byteBuffer.duplicate()); } catch (Exception e) { - LOGGER.error("Failed to read metadata", e); + LOGGER.log(Level.ERROR, "Failed to read metadata", e); throw Exceptions.propagate(e); } } diff --git a/services-examples/pom.xml b/services-examples/pom.xml index b924d66ee..5c590bef1 100644 --- a/services-examples/pom.xml +++ b/services-examples/pom.xml @@ -49,18 +49,17 @@ fastutil 8.1.1 - - org.slf4j - slf4j-api + org.apache.logging.log4j + log4j-core org.apache.logging.log4j - log4j-slf4j-impl + log4j-jpl org.apache.logging.log4j - log4j-core + log4j-slf4j-impl diff --git a/services-gateway/pom.xml b/services-gateway/pom.xml index 8bfff3973..f49ecc333 100644 --- a/services-gateway/pom.xml +++ b/services-gateway/pom.xml @@ -42,10 +42,6 @@ org.jctools jctools-core - - org.slf4j - slf4j-api - @@ -79,12 +75,12 @@ org.apache.logging.log4j - log4j-core + log4j-jpl test - com.lmax - disruptor + org.apache.logging.log4j + log4j-core test diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/GatewaySessionHandler.java b/services-gateway/src/main/java/io/scalecube/services/gateway/GatewaySessionHandler.java index 650894d59..dbe6d2be5 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/GatewaySessionHandler.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/GatewaySessionHandler.java @@ -2,15 +2,15 @@ import io.netty.buffer.ByteBuf; import io.scalecube.services.api.ServiceMessage; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; import reactor.util.context.Context; public interface GatewaySessionHandler { - Logger LOGGER = LoggerFactory.getLogger(GatewaySessionHandler.class); + Logger LOGGER = System.getLogger(GatewaySessionHandler.class.getName()); GatewaySessionHandler DEFAULT_INSTANCE = new GatewaySessionHandler() {}; @@ -59,8 +59,9 @@ default void onResponse( * @param context subscriber context */ default void onError(GatewaySession session, Throwable throwable, Context context) { - LOGGER.error( - "Exception occurred on session: {}, on context: {}, cause:", + LOGGER.log( + Level.ERROR, + "Exception occurred on session: {0,number,#}, on context: {1}", session.sessionId(), context, throwable); @@ -73,7 +74,8 @@ default void onError(GatewaySession session, Throwable throwable, Context contex * @param throwable an exception that occurred (not null) */ default void onSessionError(GatewaySession session, Throwable throwable) { - LOGGER.error("Exception occurred on session: {}, cause:", session.sessionId(), throwable); + LOGGER.log( + Level.ERROR, "Exception occurred on session: {0,number,#}", session.sessionId(), throwable); } /** @@ -86,8 +88,11 @@ default void onSessionError(GatewaySession session, Throwable throwable) { default Mono onConnectionOpen(long sessionId, Map headers) { return Mono.fromRunnable( () -> - LOGGER.debug( - "Connection opened, sessionId: {}, headers({})", sessionId, headers.size())); + LOGGER.log( + Level.DEBUG, + "Connection opened, sessionId: {0,number,#}, headers({1})", + sessionId, + headers.size())); } /** @@ -96,7 +101,7 @@ default Mono onConnectionOpen(long sessionId, Map headers) * @param session websocket session (not null) */ default void onSessionOpen(GatewaySession session) { - LOGGER.info("Session opened: {}", session); + LOGGER.log(Level.INFO, "Session opened: {0}", session); } /** @@ -105,6 +110,6 @@ default void onSessionOpen(GatewaySession session) { * @param session websocket session (not null) */ default void onSessionClose(GatewaySession session) { - LOGGER.info("Session closed: {}", session); + LOGGER.log(Level.INFO, "Session closed: {0}", session); } } diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/ReferenceCountUtil.java b/services-gateway/src/main/java/io/scalecube/services/gateway/ReferenceCountUtil.java index 1c534365e..9e8884e1c 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/ReferenceCountUtil.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/ReferenceCountUtil.java @@ -1,12 +1,12 @@ package io.scalecube.services.gateway; import io.netty.util.ReferenceCounted; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; public final class ReferenceCountUtil { - private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceCountUtil.class); + private static final Logger LOGGER = System.getLogger(ReferenceCountUtil.class.getName()); private ReferenceCountUtil() { // Do not instantiate @@ -24,7 +24,11 @@ public static boolean safestRelease(Object msg) { && ((ReferenceCounted) msg).refCnt() > 0 && ((ReferenceCounted) msg).release(); } catch (Throwable t) { - LOGGER.warn("Failed to release reference counted object: {}, cause: {}", msg, t.toString()); + LOGGER.log( + Level.WARNING, + "Failed to release reference counted object: {0}, cause: {1}", + msg, + t.toString()); return false; } } diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/client/http/HttpGatewayClientTransport.java b/services-gateway/src/main/java/io/scalecube/services/gateway/client/http/HttpGatewayClientTransport.java index ae7655f35..eea2b4c69 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/client/http/HttpGatewayClientTransport.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/client/http/HttpGatewayClientTransport.java @@ -13,6 +13,8 @@ import io.scalecube.services.transport.api.ClientChannel; import io.scalecube.services.transport.api.ClientTransport; import io.scalecube.services.transport.api.DataCodec; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.lang.reflect.Type; import java.time.Duration; import java.util.Map; @@ -20,8 +22,6 @@ import java.util.function.Function; import java.util.function.UnaryOperator; import org.reactivestreams.Publisher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.netty.NettyOutbound; @@ -33,7 +33,7 @@ public final class HttpGatewayClientTransport implements ClientChannel, ClientTransport { - private static final Logger LOGGER = LoggerFactory.getLogger(HttpGatewayClientTransport.class); + private static final Logger LOGGER = System.getLogger(HttpGatewayClientTransport.class.getName()); private static final String CONTENT_TYPE = "application/json"; private static final HttpGatewayClientCodec CLIENT_CODEC = @@ -93,7 +93,7 @@ public Mono requestResponse(ServiceMessage request, Type respons private Mono send( ServiceMessage request, HttpClientRequest clientRequest, NettyOutbound outbound) { - LOGGER.debug("Sending request: {}", request); + LOGGER.log(Level.DEBUG, "Sending request: {0}", request); // prepare request headers request.headers().forEach(clientRequest::header); // send with publisher (defer buffer cleanup to netty) @@ -127,7 +127,7 @@ private static ServiceMessage toMessage(HttpClientResponse httpResponse, ByteBuf .forEach(entry -> builder.header(entry.getKey(), entry.getValue())); ServiceMessage message = builder.build(); - LOGGER.debug("Received response: {}", message); + LOGGER.log(Level.DEBUG, "Received response: {0}", message); return message; } diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientSession.java b/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientSession.java index 24c637c35..3d67cde36 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientSession.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientSession.java @@ -8,13 +8,13 @@ import io.scalecube.services.api.ServiceMessage; import io.scalecube.services.gateway.ReferenceCountUtil; import io.scalecube.services.gateway.client.GatewayClientCodec; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.nio.channels.ClosedChannelException; import java.time.Duration; import java.util.Map; import java.util.StringJoiner; import org.jctools.maps.NonBlockingHashMapLong; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; import reactor.core.publisher.Sinks; import reactor.core.publisher.Sinks.Many; @@ -25,7 +25,8 @@ public final class WebsocketGatewayClientSession { - private static final Logger LOGGER = LoggerFactory.getLogger(WebsocketGatewayClientSession.class); + private static final Logger LOGGER = + System.getLogger(WebsocketGatewayClientSession.class.getName()); private static final ClosedChannelException CLOSED_CHANNEL_EXCEPTION = new ClosedChannelException(); @@ -61,13 +62,14 @@ public final class WebsocketGatewayClientSession { try { message = clientCodec.decode(byteBuf); } catch (Exception ex) { - LOGGER.error("Response decoder failed:", ex); + LOGGER.log(Level.ERROR, "Response decoder failed", ex); return; } // ignore messages w/o sid if (!message.headers().containsKey(STREAM_ID)) { - LOGGER.error("Ignore response: {} with null sid, session={}", message, id); + LOGGER.log( + Level.ERROR, "Ignore response: {0} with null sid, session={1}", message, id); if (message.data() != null) { ReferenceCountUtil.safestRelease(message.data()); } @@ -103,18 +105,18 @@ Many newUnicastProcessor(long sid) { } private One newMonoProcessor0(long sid) { - LOGGER.debug("Put sid={}, session={}", sid, id); + LOGGER.log(Level.DEBUG, "Put sid={0}, session={1}", sid, id); return Sinks.one(); } private Many newUnicastProcessor0(long sid) { - LOGGER.debug("Put sid={}, session={}", sid, id); + LOGGER.log(Level.DEBUG, "Put sid={0}, session={1}", sid, id); return Sinks.many().unicast().onBackpressureBuffer(); } void removeProcessor(long sid) { if (inboundProcessors.remove(sid) != null) { - LOGGER.debug("Removed sid={}, session={}", sid, id); + LOGGER.log(Level.DEBUG, "Removed sid={0}, session={1}", sid, id); } } @@ -135,7 +137,11 @@ void cancel(long sid, String qualifier) { .subscribe( null, th -> - LOGGER.error("Exception occurred on sending CANCEL signal for session={}", id, th)); + LOGGER.log( + Level.ERROR, + "Exception occurred on sending CANCEL signal for session={0}", + id, + th)); } /** @@ -155,9 +161,7 @@ public Mono onClose() { } private void handleResponse(ServiceMessage response, Object processor) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Handle response: {}, session={}", response, id); - } + LOGGER.log(Level.DEBUG, "Handle response: {0}, session={1}", response, id); try { Signal signal = null; diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientTransport.java b/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientTransport.java index a9a892b0a..1c2d22f83 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientTransport.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/client/websocket/WebsocketGatewayClientTransport.java @@ -11,6 +11,8 @@ import io.scalecube.services.gateway.client.ServiceMessageCodec; import io.scalecube.services.transport.api.ClientChannel; import io.scalecube.services.transport.api.ClientTransport; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.lang.reflect.Type; import java.time.Duration; import java.util.Map; @@ -19,8 +21,6 @@ import java.util.function.Function; import java.util.function.UnaryOperator; import org.reactivestreams.Publisher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.netty.Connection; @@ -31,7 +31,7 @@ public final class WebsocketGatewayClientTransport implements ClientChannel, ClientTransport { private static final Logger LOGGER = - LoggerFactory.getLogger(WebsocketGatewayClientTransport.class); + System.getLogger(WebsocketGatewayClientTransport.class.getName()); private static final String STREAM_ID = "sid"; private static final String CONTENT_TYPE = "application/json"; @@ -97,21 +97,23 @@ private WebsocketGatewayClientSession clientSession(HttpClient httpClient) { connection -> { final WebsocketGatewayClientSession session = new WebsocketGatewayClientSession(clientCodec, connection); - LOGGER.info("Created session: {}", session); + LOGGER.log(Level.INFO, "Created session: {0}", session); // setup shutdown hook session .onClose() - .doOnTerminate(() -> LOGGER.info("Closed session: {}", session)) + .doOnTerminate(() -> LOGGER.log(Level.INFO, "Closed session: {0}", session)) .subscribe( null, th -> - LOGGER.warn( - "Exception on closing session: {}, cause: {}", + LOGGER.log( + Level.WARNING, + "Exception on closing session: {0}, cause: {1}", session, th.toString())); return session; }) - .doOnError(ex -> LOGGER.warn("Failed to connect, cause: {}", ex.toString())) + .doOnError( + ex -> LOGGER.log(Level.WARNING, "Failed to connect, cause: {0}", ex.toString())) .toFuture() .get(); } catch (Exception e) { @@ -127,7 +129,7 @@ public Mono requestResponse(ServiceMessage request, Type respons final WebsocketGatewayClientSession session = clientSessionReference.get(); return session .send(encodeRequest(request, sid)) - .doOnSubscribe(s -> LOGGER.debug("Sending request {}", request)) + .doOnSubscribe(s -> LOGGER.log(Level.DEBUG, "Sending request {0}", request)) .then(session.newMonoProcessor(sid).asMono()) .map(msg -> ServiceMessageCodec.decodeData(msg, responseType)) .doOnCancel(() -> session.cancel(sid, request.qualifier())) @@ -143,7 +145,7 @@ public Flux requestStream(ServiceMessage request, Type responseT final WebsocketGatewayClientSession session = clientSessionReference.get(); return session .send(encodeRequest(request, sid)) - .doOnSubscribe(s -> LOGGER.debug("Sending request {}", request)) + .doOnSubscribe(s -> LOGGER.log(Level.DEBUG, "Sending request {0}", request)) .thenMany(session.newUnicastProcessor(sid).asFlux()) .map(msg -> ServiceMessageCodec.decodeData(msg, responseType)) .doOnCancel(() -> session.cancel(sid, request.qualifier())) diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/http/HttpGatewayAcceptor.java b/services-gateway/src/main/java/io/scalecube/services/gateway/http/HttpGatewayAcceptor.java index 3a04f22de..8ba85b7fb 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/http/HttpGatewayAcceptor.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/http/HttpGatewayAcceptor.java @@ -18,10 +18,10 @@ import io.scalecube.services.exceptions.ServiceProviderErrorMapper; import io.scalecube.services.gateway.ReferenceCountUtil; import io.scalecube.services.transport.api.DataCodec; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.function.BiFunction; import org.reactivestreams.Publisher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; import reactor.netty.ByteBufMono; import reactor.netty.http.server.HttpServerRequest; @@ -30,7 +30,7 @@ public class HttpGatewayAcceptor implements BiFunction> { - private static final Logger LOGGER = LoggerFactory.getLogger(HttpGatewayAcceptor.class); + private static final Logger LOGGER = System.getLogger(HttpGatewayAcceptor.class.getName()); private static final String ERROR_NAMESPACE = "io.scalecube.services.error"; @@ -48,8 +48,9 @@ public class HttpGatewayAcceptor @Override public Publisher apply(HttpServerRequest httpRequest, HttpServerResponse httpResponse) { - LOGGER.debug( - "Accepted request: {}, headers: {}, params: {}", + LOGGER.log( + Level.DEBUG, + "Accepted request: {0}, headers: {}, params: {1}", httpRequest, httpRequest.requestHeaders(), httpRequest.params()); @@ -132,7 +133,7 @@ private ByteBuf encodeData(Object data, String dataFormat) { DataCodec.getInstance(dataFormat).encode(new ByteBufOutputStream(byteBuf), data); } catch (Throwable t) { ReferenceCountUtil.safestRelease(byteBuf); - LOGGER.error("Failed to encode data: {}", data, t); + LOGGER.log(Level.ERROR, "Failed to encode data: {0}", data, t); return Unpooled.EMPTY_BUFFER; } diff --git a/services-gateway/src/main/java/io/scalecube/services/gateway/websocket/WebsocketGatewaySession.java b/services-gateway/src/main/java/io/scalecube/services/gateway/websocket/WebsocketGatewaySession.java index 1d97d9db1..80d96ff3f 100644 --- a/services-gateway/src/main/java/io/scalecube/services/gateway/websocket/WebsocketGatewaySession.java +++ b/services-gateway/src/main/java/io/scalecube/services/gateway/websocket/WebsocketGatewaySession.java @@ -5,13 +5,13 @@ import io.scalecube.services.api.ServiceMessage; import io.scalecube.services.gateway.GatewaySession; import io.scalecube.services.gateway.GatewaySessionHandler; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; import org.jctools.maps.NonBlockingHashMapLong; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.Disposable; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -21,7 +21,7 @@ public final class WebsocketGatewaySession implements GatewaySession { - private static final Logger LOGGER = LoggerFactory.getLogger(WebsocketGatewaySession.class); + private static final Logger LOGGER = System.getLogger(WebsocketGatewaySession.class.getName()); private static final Predicate SEND_PREDICATE = f -> true; @@ -174,9 +174,11 @@ public boolean dispose(Long streamId) { Disposable disposable = subscriptions.remove(streamId); result = disposable != null; if (result) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Dispose subscription by sid={}, session={}", streamId, sessionId); - } + LOGGER.log( + Level.DEBUG, + "Dispose subscription by sid={0,number,#}, session={1,number,#}", + streamId, + sessionId); disposable.dispose(); } } @@ -200,16 +202,16 @@ public void register(Long streamId, Disposable disposable) { result = subscriptions.putIfAbsent(streamId, disposable) == null; } if (result) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Registered subscription by sid={}, session={}", streamId, sessionId); - } + LOGGER.log( + Level.DEBUG, + "Registered subscription by sid={0,number,#}, session={1,number,#}", + streamId, + sessionId); } } private void clearSubscriptions() { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Clear subscriptions on session={}", sessionId); - } + LOGGER.log(Level.DEBUG, "Clear subscriptions on session={0,number,#}", sessionId); subscriptions.forEach((sid, disposable) -> disposable.dispose()); subscriptions.clear(); } diff --git a/services-gateway/src/test/java/io/scalecube/services/gateway/GatewaySessionHandlerImpl.java b/services-gateway/src/test/java/io/scalecube/services/gateway/GatewaySessionHandlerImpl.java index f036f1049..d49ed1f3a 100644 --- a/services-gateway/src/test/java/io/scalecube/services/gateway/GatewaySessionHandlerImpl.java +++ b/services-gateway/src/test/java/io/scalecube/services/gateway/GatewaySessionHandlerImpl.java @@ -3,6 +3,7 @@ import io.netty.buffer.ByteBuf; import io.scalecube.services.api.ServiceMessage; import io.scalecube.services.auth.Authenticator; +import java.lang.System.Logger.Level; import java.util.Optional; import reactor.util.context.Context; @@ -30,12 +31,12 @@ public ServiceMessage mapMessage( @Override public void onSessionOpen(GatewaySession s) { - LOGGER.info("Session opened: {}", s); + LOGGER.log(Level.INFO, "Session opened: {0}", s); } @Override public void onSessionClose(GatewaySession session) { - LOGGER.info("Session removed: {}", session); + LOGGER.log(Level.INFO, "Session removed: {0}", session); authRegistry.removeAuth(session.sessionId()); } } diff --git a/services-security/src/main/java/io/scalecube/services/security/ServiceTokenAuthenticator.java b/services-security/src/main/java/io/scalecube/services/security/ServiceTokenAuthenticator.java index fc1f4e019..fb0b7e7fb 100644 --- a/services-security/src/main/java/io/scalecube/services/security/ServiceTokenAuthenticator.java +++ b/services-security/src/main/java/io/scalecube/services/security/ServiceTokenAuthenticator.java @@ -3,9 +3,9 @@ import io.scalecube.security.tokens.jwt.JwtTokenResolver; import io.scalecube.services.auth.Authenticator; import io.scalecube.services.exceptions.UnauthorizedException; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -16,7 +16,7 @@ */ public final class ServiceTokenAuthenticator implements Authenticator { - private static final Logger LOGGER = LoggerFactory.getLogger(ServiceTokenAuthenticator.class); + private static final Logger LOGGER = System.getLogger(ServiceTokenAuthenticator.class.getName()); private JwtTokenResolver tokenResolver; private ServiceTokenMapper tokenMapper; @@ -98,7 +98,9 @@ public Mono apply(Map credentials) { .resolve(serviceToken) .map(authDataMapper::map) .retryWhen(retryStrategy) - .doOnError(th -> LOGGER.error("Failed to authenticate, cause: {}", th.toString())) + .doOnError( + th -> + LOGGER.log(Level.ERROR, "Failed to authenticate, cause: {0}", th.toString())) .onErrorMap(th -> new UnauthorizedException("Authentication failed")) .switchIfEmpty(Mono.error(new UnauthorizedException("Authentication failed"))); }); diff --git a/services-transport-parent/services-transport-rsocket/pom.xml b/services-transport-parent/services-transport-rsocket/pom.xml index 12666d855..ec54232b9 100644 --- a/services-transport-parent/services-transport-rsocket/pom.xml +++ b/services-transport-parent/services-transport-rsocket/pom.xml @@ -15,12 +15,6 @@ scalecube-services-api ${project.version} - - - org.slf4j - slf4j-api - - io.rsocket rsocket-core diff --git a/services/pom.xml b/services/pom.xml index 674e90127..9f9b7e804 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -24,10 +24,6 @@ io.projectreactor reactor-core - - org.slf4j - slf4j-api - org.jctools jctools-core @@ -66,6 +62,10 @@ log4j-slf4j-impl test + + org.apache.logging.log4j + log4j-jpl + org.apache.logging.log4j log4j-core diff --git a/services/src/main/java/io/scalecube/services/registry/ServiceRegistryImpl.java b/services/src/main/java/io/scalecube/services/registry/ServiceRegistryImpl.java index 7619703f9..db2bc3c64 100644 --- a/services/src/main/java/io/scalecube/services/registry/ServiceRegistryImpl.java +++ b/services/src/main/java/io/scalecube/services/registry/ServiceRegistryImpl.java @@ -8,6 +8,8 @@ import io.scalecube.services.methods.MethodInfo; import io.scalecube.services.methods.ServiceMethodInvoker; import io.scalecube.services.registry.api.ServiceRegistry; +import java.lang.System.Logger; +import java.lang.System.Logger.Level; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -19,12 +21,10 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import org.jctools.maps.NonBlockingHashMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class ServiceRegistryImpl implements ServiceRegistry { - private static final Logger LOGGER = LoggerFactory.getLogger(ServiceRegistryImpl.class); + private static final Logger LOGGER = System.getLogger(ServiceRegistryImpl.class.getName()); // todo how to remove it (tags problem)? private final Map serviceEndpoints = new NonBlockingHashMap<>(); @@ -65,7 +65,7 @@ public List lookupService(ServiceMessage request) { public boolean registerService(ServiceEndpoint serviceEndpoint) { boolean success = serviceEndpoints.putIfAbsent(serviceEndpoint.id(), serviceEndpoint) == null; if (success) { - LOGGER.debug("ServiceEndpoint registered: {}", serviceEndpoint); + LOGGER.log(Level.DEBUG, "ServiceEndpoint registered: {0}", serviceEndpoint); serviceEndpoint .serviceReferences() .forEach( @@ -81,7 +81,7 @@ public boolean registerService(ServiceEndpoint serviceEndpoint) { public ServiceEndpoint unregisterService(String endpointId) { ServiceEndpoint serviceEndpoint = serviceEndpoints.remove(endpointId); if (serviceEndpoint != null) { - LOGGER.debug("ServiceEndpoint unregistered: {}", serviceEndpoint); + LOGGER.log(Level.DEBUG, "ServiceEndpoint unregistered: {0}", serviceEndpoint); List serviceReferencesOfEndpoint = serviceReferencesByQualifier.values().stream() @@ -144,7 +144,7 @@ public void registerService(ServiceInfo serviceInfo) { private void checkMethodInvokerDoesntExist(MethodInfo methodInfo) { if (methodInvokers.containsKey(methodInfo.qualifier()) || methodInvokers.containsKey(methodInfo.oldQualifier())) { - LOGGER.error("MethodInvoker already exists, methodInfo: {}", methodInfo); + LOGGER.log(Level.ERROR, "MethodInvoker already exists, methodInfo: {0}", methodInfo); throw new IllegalStateException("MethodInvoker already exists"); } }