Skip to content

[ISSUE-103]: Migrate away from log4j 1.x #104

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions apps/sparkpost-documentor-app/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Root logger option
log4j.rootLogger=DEBUG, stdout
log4j.rootLogger=DEBUG, STDOUT

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout=org.apache.logging.log4j.ConsoleAppender
log4j.appender.stdout.Target=SYSTEM_OUT
log4j.appender.stdout.layout=org.apache.logging.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


8 changes: 6 additions & 2 deletions apps/sparkpost-documentor-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
29 changes: 13 additions & 16 deletions apps/sparkpost-javamail-app/log4j.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
</layout>
</appender>

<root>
<priority value ="debug" />
<appender-ref ref="console" />
</root>

</log4j:configuration>
<Configuration>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%-5p %c{1} - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="console"/>
<AppenderRef ref="testFile"/>
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.Level;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -41,8 +41,8 @@
public class App extends SparkPostBaseApp {

public static void main(String[] args) throws Exception {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

App app = new App();
app.runApp();
}
Expand Down
8 changes: 4 additions & 4 deletions apps/sparkpost-samples-app/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Root logger option
log4j.rootLogger=DEBUG, stdout
log4j.rootLogger=DEBUG, STDOUT

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout=org.apache.logging.log4j.ConsoleAppender
log4j.appender.stdout.Target=SYSTEM_OUT
log4j.appender.stdout.layout=org.apache.logging.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


9 changes: 6 additions & 3 deletions apps/sparkpost-samples-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
<groupId>com.sparkpost</groupId>
<artifactId>sparkpost-lib</artifactId>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostAccessForbiddenException;
Expand All @@ -19,12 +21,12 @@
*/
public class BadApiKeyErrorSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(BadApiKeyErrorSample.class);
static final Logger logger = LogManager.getLogger(BadApiKeyErrorSample.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

BadApiKeyErrorSample sample = new BadApiKeyErrorSample();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -17,12 +19,12 @@

public class ForceTransportError extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(ForceTransportError.class);
static final Logger logger = LogManager.getLogger(ForceTransportError.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

ForceTransportError app = new ForceTransportError();
app.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -25,12 +27,12 @@

public class SendEmailErrorSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(SendEmailErrorSample.class);
static final Logger logger = LogManager.getLogger(SendEmailErrorSample.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

SendEmailErrorSample sample = new SendEmailErrorSample();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostErrorServerResponseException;
Expand All @@ -25,12 +27,12 @@

public class SendInvalidFromAddress extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(SendInvalidFromAddress.class);
static final Logger logger = LogManager.getLogger(SendInvalidFromAddress.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

SendInvalidFromAddress sample = new SendInvalidFromAddress();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -33,12 +35,12 @@
*/
public class CreateRecipientListSample extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
static final Logger logger = LogManager.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

CreateRecipientListSample app = new CreateRecipientListSample();
app.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -15,19 +16,20 @@
import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp;
import com.sparkpost.transport.IRestConnection;
import com.sparkpost.transport.RestConnection;
import org.apache.logging.log4j.core.config.Configurator;

/**
* This class demonstrates how to store and RFC822 template in SparkPost
* Warning: RFC822 templates are only manageable via API and not from website directly.
*/
public class CreateTemplateFromFile extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
private static final Logger logger = LogManager.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

CreateTemplateFromFile sample = new CreateTemplateFromFile();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import java.io.IOException;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -22,12 +24,12 @@
*/
public class CreateTemplateFromFile2 extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
private static final Logger logger = LogManager.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

CreateTemplateFromFile2 sample = new CreateTemplateFromFile2();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import java.io.IOException;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -19,12 +21,12 @@

public class CreateTemplateSimple extends SparkPostBaseApp {

private static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
private static final Logger logger = LogManager.getLogger(CreateTemplateSimple.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

CreateTemplateSimple sample = new CreateTemplateSimple();
sample.runApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import java.io.IOException;
import java.util.List;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;

import com.sparkpost.Client;
import com.sparkpost.exception.SparkPostException;
Expand All @@ -16,18 +17,19 @@
import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp;
import com.sparkpost.transport.IRestConnection;
import com.sparkpost.transport.RestConnection;
import org.apache.logging.log4j.core.config.Configurator;

/**
* Delete all test templates created by the sample code
*/
public class DeleteSampleTemplates extends SparkPostBaseApp {

static final Logger logger = Logger.getLogger(DeleteSampleTemplates.class);
static final Logger logger = LogManager.getLogger(DeleteSampleTemplates.class);

private Client client;

public static void main(String[] args) throws SparkPostException, IOException {
Logger.getRootLogger().setLevel(Level.DEBUG);
Configurator.setRootLevel(Level.DEBUG);

DeleteSampleTemplates sample = new DeleteSampleTemplates();
sample.runApp();
Expand Down
Loading