Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Switch from logging through SLF4J to Log4J v2.x (#376)
Browse files Browse the repository at this point in the history
The API is better, as it allows truly async calls. Also, SLF4J appears to be dead with months of no activity in the project.
  • Loading branch information
triceo authored Jan 26, 2019
1 parent fca64ec commit 9097514
Show file tree
Hide file tree
Showing 315 changed files with 1,303 additions and 1,315 deletions.
46 changes: 18 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 The RoboZonky Project
~ Copyright 2019 The RoboZonky Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@
<version.org.junit.platform>1.${version.org.junit5}</version.org.junit.platform>
<version.org.mockito>2.23.11</version.org.mockito>
<version.org.mock-server>5.5.1</version.org.mock-server>
<version.org.slf4j>1.7.25</version.org.slf4j>
<version.org.apache.logging.log4j>2.11.1</version.org.apache.logging.log4j>
<!-- For whatever reason, SMTP auth fails in Windows with the default version. -->
<version.com.sun.mail>1.6.2</version.com.sun.mail>
<!--
Expand Down Expand Up @@ -152,23 +152,11 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
<exclusions>
<exclusion> <!-- Needs to be replaced by SLF4J. -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.10</version>
<exclusions>
<exclusion> <!-- Needs to be replaced by SLF4J. -->
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Email notifications. -->
<dependency>
Expand Down Expand Up @@ -382,16 +370,22 @@
<artifactId>jackson-coreutils</artifactId>
<version>1.8</version>
</dependency>
<!-- Logging. -->
<!-- Logging. We log through the LOG4J 2.x API, but we pass it to Logback for backwards compatibility. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.org.slf4j}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${version.org.apache.logging.log4j}</version>
</dependency>
<dependency> <!-- commons-logging needs to be excluded everywhere in favor of this, -->
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${version.org.slf4j}</version>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${version.org.apache.logging.log4j}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${version.org.apache.logging.log4j}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down Expand Up @@ -444,11 +438,6 @@
<configuration>
<rules>
<banDuplicatePomDependencyVersions />
<bannedDependencies>
<excludes>
<exclude>commons-logging</exclude> <!-- Is replaced with SLF4J. -->
</excludes>
</bannedDependencies>
<dependencyConvergence />
<reactorModuleConvergence>
<ignoreModuleDependencies>true</ignoreModuleDependencies>
Expand Down Expand Up @@ -546,14 +535,15 @@
<ignoredUnusedDeclaredDependency>com.github.robozonky</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>com.sun.mail</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>ch.qos.logback</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.slf4j</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.jboss.resteasy</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.jboss.spec.javax.xml.bind</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.jboss.spec.javay.ws.rs</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.junit.jupiter</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>ch.qos.logback</ignoredUsedUndeclaredDependency>
<ignoredUsedUndeclaredDependency>org.slf4j</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
</configuration>
</execution>
Expand Down
10 changes: 5 additions & 5 deletions robozonky-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 The RoboZonky Project
~ Copyright 2019 The RoboZonky Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,8 +52,8 @@
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
Expand Down Expand Up @@ -89,8 +89,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
175 changes: 175 additions & 0 deletions robozonky-api/revapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,181 @@
"old": "method java.lang.String com.github.robozonky.api.remote.entities.ZonkyApiToken::getScope()",
"new": "method com.github.robozonky.api.remote.enums.OAuthScopes com.github.robozonky.api.remote.entities.ZonkyApiToken::getScope()",
"justification": "OAuth Token Scope is an Enum now."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.BankAccount",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.BlockedAmount",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.BorrowerRelatedInvestmentInfo",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.CurrentOverview",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.DateDescriptor",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.ExpectedPayment",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Instalment",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.InsurancePolicyPeriod",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.MonthlySuperInvestorOverview",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.MyInvestment",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.OtherInvestments",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.OverallOverview",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.OverallPortfolio",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Participation",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Photo",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.PurchaseRequest",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.RawDevelopment",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.RawInvestment",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.RawLoan",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Restrictions",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.RiskPortfolio",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.SellRequest",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Statistics",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.SuperInvestorOverview",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Transaction",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.Wallet",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.field.removed",
"old": "field com.github.robozonky.api.remote.entities.BaseEntity.LOGGER @ com.github.robozonky.api.remote.entities.ZonkyApiToken",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "class org.apache.logging.log4j.Level",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.Logger",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.Marker",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.message.Message",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.message.MessageFactory",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.util.MessageSupplier",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "interface org.apache.logging.log4j.util.Supplier<T extends java.lang.Object>",
"justification": "Logging goes through Log4J instead of SLF4J."
},
{
"code": "java.class.externalClassExposedInAPI",
"new": "enum org.apache.logging.log4j.spi.StandardLevel",
"justification": "Logging goes through Log4J instead of SLF4J."
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The RoboZonky Project
* Copyright 2019 The RoboZonky Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,8 +24,8 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.github.robozonky.internal.util.ToStringBuilder;
import io.vavr.Lazy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* All JAX-RS entity classes in this package should extend this class in order to be able to gracefully handle
Expand All @@ -36,7 +36,7 @@ abstract class BaseEntity {

private static final Set<String> CHANGES_ALREADY_NOTIFIED = new HashSet<>(0);
@XmlTransient
protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LogManager.getLogger(this.getClass());
@XmlTransient
private final Lazy<String> toString = Lazy.of(() -> ToStringBuilder.createFor(this, "toString"));

Expand All @@ -48,14 +48,14 @@ private boolean hasBeenCalledBefore(final String key) {
@JsonAnyGetter
void handleUnknownGetter(final String key) {
if (!hasBeenCalledBefore(key)) {
LOGGER.info("Trying to get value of unknown property '{}'. Indicates an unexpected API change.", key);
logger.info("Trying to get value of unknown property '{}'. Indicates an unexpected API change.", key);
}
}

@JsonAnySetter
void handleUnknownSetter(final String key, final Object value) {
if (!hasBeenCalledBefore(key)) {
LOGGER.info("Trying to set value '{}' to an unknown property '{}'. Indicates an unexpected API change.",
logger.info("Trying to set value '{}' to an unknown property '{}'. Indicates an unexpected API change.",
value, key);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 The RoboZonky Project
* Copyright 2019 The RoboZonky Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,13 +34,13 @@
import com.github.robozonky.internal.util.RandomUtil;
import com.github.robozonky.internal.util.ToStringBuilder;
import io.vavr.Lazy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@SuppressWarnings("unchecked")
abstract class AbstractMutableLoanImpl<T extends MutableMarketplaceLoan<T>> implements MutableMarketplaceLoan<T> {

protected final Logger LOGGER = LoggerFactory.getLogger(getClass());
protected final Logger logger = LogManager.getLogger(getClass());
private boolean topped, covered, published, questionsAllowed, insuranceActive;
private int id, termInMonths, investmentsCount, questionsCount, userId, activeLoansCount, amount;
private int remainingInvestment;
Expand All @@ -62,7 +62,7 @@ abstract class AbstractMutableLoanImpl<T extends MutableMarketplaceLoan<T>> impl
}

AbstractMutableLoanImpl(final RawLoan original) {
LOGGER.trace("Sanitizing loan #{}.", original.getId());
logger.trace("Sanitizing loan #{}.", original.getId());
this.activeLoansCount = original.getActiveLoansCount();
this.amount = (int) original.getAmount();
this.datePublished = original.getDatePublished();
Expand Down
Loading

0 comments on commit 9097514

Please sign in to comment.