Skip to content

Commit

Permalink
Merge pull request #195 from com-pas/replace-slf4j-with-log4j2
Browse files Browse the repository at this point in the history
Switch from slf4j to log4j2
  • Loading branch information
Dennis Labordus authored Nov 21, 2022
2 parents f089189 + ae48206 commit 16401ee
Show file tree
Hide file tree
Showing 22 changed files with 241 additions and 71 deletions.
14 changes: 7 additions & 7 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ 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>

<dependency>
Expand All @@ -52,11 +57,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>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.core.commons;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.exception.CompasException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Expand All @@ -27,7 +27,7 @@
import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.CONVERT_TO_STRING_ERROR;

public class ElementConverter {
private static final Logger LOGGER = LoggerFactory.getLogger(ElementConverter.class);
private static final Logger LOGGER = LogManager.getLogger(ElementConverter.class);

public String convertToString(Element element) {
return convertToString(element, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.exception.CompasException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
Expand All @@ -30,7 +30,7 @@
import static org.lfenergy.compas.core.commons.exception.CompasErrorCode.*;

public abstract class MarshallerWrapper<T> {
private static final Logger LOGGER = LoggerFactory.getLogger(MarshallerWrapper.class);
private static final Logger LOGGER = LogManager.getLogger(MarshallerWrapper.class);

private final Unmarshaller jaxbUnmarshaller;
private final Marshaller jaxbMarshaller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.core.commons.constraint.impl;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.constraint.XmlAnyElementValid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;

import javax.validation.ConstraintValidator;
Expand All @@ -17,7 +17,7 @@
* element are correct and also if the element(s) in the list have the correct Local Name and the correct Namespace.
*/
public class XmlAnyElementConstraintValidator implements ConstraintValidator<XmlAnyElementValid, List<Element>> {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlAnyElementConstraintValidator.class);
private static final Logger LOGGER = LogManager.getLogger(XmlAnyElementConstraintValidator.class);

private String elementName;
private String elementNamespace;
Expand Down
23 changes: 23 additions & 0 deletions commons/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>

<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ SPDX-License-Identifier: Apache-2.0

<compas.scl.xsd.version>0.0.4</compas.scl.xsd.version>
<quarkus.platform.version>2.14.1.Final</quarkus.platform.version>
<slf4j.version>2.0.4</slf4j.version>
<jaxb.bind.version>2.3.7</jaxb.bind.version>
<log4j2.version>2.19.0</log4j2.version>
<openpojo.version>0.9.1</openpojo.version>
</properties>

Expand Down Expand Up @@ -91,14 +91,14 @@ SPDX-License-Identifier: Apache-2.0
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>

<dependency>
Expand Down
15 changes: 7 additions & 8 deletions rest-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ 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>

<dependency>
Expand All @@ -54,11 +59,5 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>resteasy-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.core.rest.exception;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.exception.CompasException;
import org.lfenergy.compas.core.commons.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

@Provider
public class CompasExceptionHandler implements ExceptionMapper<CompasException> {
private static final Logger LOGGER = LoggerFactory.getLogger(CompasExceptionHandler.class);
private static final Logger LOGGER = LogManager.getLogger(CompasExceptionHandler.class);

@Override
public Response toResponse(CompasException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.core.rest.exception;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.validation.ConstraintViolationException;
import javax.ws.rs.core.Response;
Expand All @@ -16,7 +16,7 @@

@Provider
public class ConstraintViolationExceptionHandler implements ExceptionMapper<ConstraintViolationException> {
private static final Logger LOGGER = LoggerFactory.getLogger(ConstraintViolationExceptionHandler.class);
private static final Logger LOGGER = LogManager.getLogger(ConstraintViolationExceptionHandler.class);

@Override
public Response toResponse(ConstraintViolationException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.core.rest.exception;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lfenergy.compas.core.commons.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
Expand All @@ -15,7 +15,7 @@

@Provider
public class GenericExceptionHandler implements ExceptionMapper<Throwable> {
private static final Logger LOGGER = LoggerFactory.getLogger(GenericExceptionHandler.class);
private static final Logger LOGGER = LogManager.getLogger(GenericExceptionHandler.class);

public static final String ERROR_MESSAGE = "Unknown exception occurred.";

Expand Down
23 changes: 23 additions & 0 deletions rest-commons/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>

<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
10 changes: 10 additions & 0 deletions scl-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ SPDX-License-Identifier: Apache-2.0
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>

<dependency>
<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>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
23 changes: 23 additions & 0 deletions scl-extension/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>

<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
14 changes: 7 additions & 7 deletions scl2003/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ 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>

<dependency>
Expand All @@ -60,11 +65,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>
</dependencies>

<build>
Expand Down
23 changes: 23 additions & 0 deletions scl2003/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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>

<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
14 changes: 7 additions & 7 deletions scl2007b/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ 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>

<dependency>
Expand All @@ -60,11 +65,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>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit 16401ee

Please sign in to comment.