Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace SLF4J with Log4j2 #157

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SPDX-License-Identifier: Apache-2.0
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>jaxrs-commons</artifactId>
<artifactId>rest-commons</artifactId>
</dependency>

<dependency>
Expand All @@ -52,27 +52,34 @@ SPDX-License-Identifier: Apache-2.0
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-jwt</artifactId>
<artifactId>quarkus-resteasy-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
<artifactId>quarkus-hibernate-validator</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
<artifactId>quarkus-smallrye-jwt</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jaxb</artifactId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>log4j2-jboss-logmanager</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>

<!-- Test Dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
@RegisterForReflection(targets = {com.powsybl.sld.library.Components.class,
com.powsybl.sld.library.Component.class,
org.lfenergy.compas.core.jaxrs.model.ErrorResponse.class,
org.lfenergy.compas.core.jaxrs.model.ErrorMessage.class})
org.lfenergy.compas.core.commons.model.ErrorResponse.class,
org.lfenergy.compas.core.commons.model.ErrorMessage.class})
public class CompasSclAutoAlignmentConfiguration {
@Produces
@ApplicationScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
package org.lfenergy.compas.scl.auto.alignment.rest.v1;

import io.quarkus.security.Authenticated;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.microprofile.jwt.JsonWebToken;
import org.lfenergy.compas.scl.auto.alignment.rest.UserInfoProperties;
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignRequest;
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignResponse;
import org.lfenergy.compas.scl.auto.alignment.rest.v1.model.SclAutoAlignSVGRequest;
import org.lfenergy.compas.scl.auto.alignment.service.SclAutoAlignmentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
Expand All @@ -26,7 +26,7 @@
@RequestScoped
@Path("/auto/alignment/v1")
public class SclAutoAlignmentResource {
private static final Logger LOGGER = LoggerFactory.getLogger(SclAutoAlignmentResource.class);
private static final Logger LOGGER = LogManager.getLogger(SclAutoAlignmentResource.class);

private final SclAutoAlignmentService sclAutoAlignmentService;

Expand All @@ -45,6 +45,8 @@ public SclAutoAlignmentResource(SclAutoAlignmentService compasCimMappingService)
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public SclAutoAlignResponse alignment(@Valid SclAutoAlignRequest request) {
LOGGER.info("Auto align SCL for Substation(s) {}.", request.getSubstationNames());

String who = jsonWebToken.getClaim(userInfoProperties.who());
LOGGER.trace("Username used for Who {}", who);

Expand All @@ -58,6 +60,7 @@ public SclAutoAlignResponse alignment(@Valid SclAutoAlignRequest request) {
@Produces(MediaType.APPLICATION_SVG_XML)
@Path("/svg")
public String svg(@Valid SclAutoAlignSVGRequest request) {
LOGGER.info("Creating SVG for Substation {}.", request.getSubstationName());
return sclAutoAlignmentService.getSVG(request.getSclData(), request.getSubstationName());
}
}
5 changes: 3 additions & 2 deletions app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ quarkus.log.category."org.lfenergy.compas.scl.auto.alignment".level = INFO
quarkus.index-dependency.compas-commons.group-id = org.lfenergy.compas.core
quarkus.index-dependency.compas-commons.artifact-id = commons

quarkus.index-dependency.jaxrs-commons.group-id = org.lfenergy.compas.core
quarkus.index-dependency.jaxrs-commons.artifact-id = jaxrs-commons
quarkus.index-dependency.rest-commons.group-id = org.lfenergy.compas.core
quarkus.index-dependency.rest-commons.artifact-id = rest-commons

quarkus.index-dependency.jaxb-api.group-id = org.jboss.spec.javax.xml.bind
quarkus.index-dependency.jaxb-api.artifact-id = jboss-jaxb-api_2.3_spec
Expand All @@ -32,6 +32,7 @@ quarkus.native.resources.includes=ConvergenceLibrary/*.*,*.css
%dev.quarkus.http.cors = true

%dev.quarkus.log.level = DEBUG
%dev.quarkus.log.category."com.powsybl".level = INFO
%dev.quarkus.log.category."org.lfenergy.compas.scl.auto.alignment".level = DEBUG

# Smallrye JWT Properties (Microprofile)
Expand Down
23 changes: 17 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ SPDX-License-Identifier: Apache-2.0
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<sonarqube-plugin.version>3.2.0</sonarqube-plugin.version>

<compas.core.version>0.9.3</compas.core.version>
<compas.core.version>0.11.0</compas.core.version>

<quarkus.platform.version>2.14.1.Final</quarkus.platform.version>
<slf4j.version>2.0.4</slf4j.version>
<log4j2.version>2.19.0</log4j2.version>
<powsybl.sld.version>3.0.0</powsybl.sld.version>
<gson.version>2.10</gson.version>
<openpojo.version>0.9.1</openpojo.version>
Expand Down Expand Up @@ -76,7 +76,7 @@ SPDX-License-Identifier: Apache-2.0
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>jaxrs-commons</artifactId>
<artifactId>rest-commons</artifactId>
<version>${compas.core.version}</version>
</dependency>

Expand All @@ -99,9 +99,20 @@ SPDX-License-Identifier: Apache-2.0
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<!-- Bridge is needed for other dependency -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>

<dependency>
Expand Down
20 changes: 13 additions & 7 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,19 @@ SPDX-License-Identifier: Apache-2.0
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- Bridge is needed for other dependency -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test Dependencies -->
Expand All @@ -57,11 +68,6 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.openpojo</groupId>
<artifactId>openpojo</artifactId>
Expand Down
27 changes: 27 additions & 0 deletions service/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2022 Alliander N.V.

SPDX-License-Identifier: Apache-2.0
-->
<Configuration strict="true" name="TestConfiguration">
<Appenders>
<Appender type="Console" name="STDOUT">
<Layout type="PatternLayout" pattern="%d %p %C{3.} [%t] %m%n"/>
</Appender>
</Appenders>

<Loggers>
<Logger name="org.lfenergy.compas" level="debug" additivity="false">
<AppenderRef ref="STDOUT"/>
</Logger>

<Logger name="com.powsybl" level="info" additivity="false">
<AppenderRef ref="STDOUT"/>
</Logger>

<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>