Skip to content

Commit 571cf0f

Browse files
authored
dataflow: avoid importing log4j at all (GoogleCloudPlatform#6599)
* dataflow: avoid importing log4j at all * revert styling changes * revert styling changes * fix lint issues * use Beam 2.32 to avoid test failure * update to Java 11 * try Beam 2.33
1 parent c3a420b commit 571cf0f

File tree

8 files changed

+56
-56
lines changed

8 files changed

+56
-56
lines changed

dataflow/encryption-keys/pom.xml

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
<maven.compiler.target>11</maven.compiler.target>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636

37-
<beam.version>2.31.0</beam.version>
37+
<beam.version>2.34.0</beam.version>
3838

3939
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
4040
<maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
4141
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
4242
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
43-
<log4j2.version>2.17.0</log4j2.version>
43+
<slf4j.version>1.7.32</slf4j.version>
4444
</properties>
4545

4646
<repositories>
@@ -132,14 +132,14 @@
132132

133133
<dependencies>
134134
<dependency>
135-
<groupId>org.apache.logging.log4j</groupId>
136-
<artifactId>log4j-api</artifactId>
137-
<version>${log4j2.version}</version>
135+
<groupId>org.slf4j</groupId>
136+
<artifactId>slf4j-api</artifactId>
137+
<version>${slf4j.version}</version>
138138
</dependency>
139139
<dependency>
140-
<groupId>org.apache.logging.log4j</groupId>
141-
<artifactId>log4j-core</artifactId>
142-
<version>${log4j2.version}</version>
140+
<groupId>org.slf4j</groupId>
141+
<artifactId>slf4j-jdk14</artifactId>
142+
<version>${slf4j.version}</version>
143143
<scope>runtime</scope>
144144
</dependency>
145145

dataflow/flex-templates/kafka_to_bigquery/pom.xml

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
<maven.compiler.target>11</maven.compiler.target>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636

37-
<beam.version>2.31.0</beam.version>
37+
<beam.version>2.34.0</beam.version>
3838
<kafka.version>7.0.0-ce</kafka.version>
3939

4040
<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
4141
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
4242
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
4343
<maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
44-
<log4j2.version>2.17.0</log4j2.version>
44+
<slf4j.version>1.7.32</slf4j.version>
4545
</properties>
4646

4747
<repositories>
@@ -128,14 +128,14 @@
128128

129129
<dependencies>
130130
<dependency>
131-
<groupId>org.apache.logging.log4j</groupId>
132-
<artifactId>log4j-api</artifactId>
133-
<version>${log4j2.version}</version>
131+
<groupId>org.slf4j</groupId>
132+
<artifactId>slf4j-api</artifactId>
133+
<version>${slf4j.version}</version>
134134
</dependency>
135135
<dependency>
136-
<groupId>org.apache.logging.log4j</groupId>
137-
<artifactId>log4j-core</artifactId>
138-
<version>${log4j2.version}</version>
136+
<groupId>org.slf4j</groupId>
137+
<artifactId>slf4j-jdk14</artifactId>
138+
<version>${slf4j.version}</version>
139139
<scope>runtime</scope>
140140
</dependency>
141141

dataflow/flex-templates/kafka_to_bigquery/src/main/java/org/apache/beam/samples/KafkaToBigQuery.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@
3939
import org.apache.beam.sdk.transforms.windowing.Window;
4040
import org.apache.beam.sdk.values.TypeDescriptor;
4141
import org.apache.kafka.common.serialization.StringDeserializer;
42-
import org.apache.logging.log4j.LogManager;
43-
import org.apache.logging.log4j.Logger;
4442
import org.joda.time.Duration;
4543
import org.joda.time.Instant;
44+
import org.slf4j.Logger;
45+
import org.slf4j.LoggerFactory;
4646

4747
/**
4848
* An Apache Beam pipeline that reads JSON encoded messages from Kafka and
4949
* writes them to a BigQuery table.
5050
*/
5151
public class KafkaToBigQuery {
52-
private static final Logger LOG = LogManager.getLogger(KafkaToBigQuery.class);
52+
private static final Logger LOG = LoggerFactory.getLogger(KafkaToBigQuery.class);
5353
private static final Gson GSON = new Gson();
5454

5555
public interface Options extends StreamingOptions {
@@ -59,8 +59,8 @@ public interface Options extends StreamingOptions {
5959

6060
void setInputTopic(String value);
6161

62-
@Description(
63-
"BigQuery table to write to, in the form 'project:dataset.table' or 'dataset.table'.")
62+
@Description("BigQuery table to write to, in the form "
63+
+ "'project:dataset.table' or 'dataset.table'.")
6464
@Default.String("beam_samples.streaming_beam_sql")
6565
String getOutputTable();
6666

dataflow/flex-templates/streaming_beam_sql/pom.xml

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
<maven.compiler.target>11</maven.compiler.target>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3636

37-
<beam.version>2.31.0</beam.version>
37+
<beam.version>2.34.0</beam.version>
3838

3939
<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
4040
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
4141
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
4242
<maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
43-
<log4j2.version>2.17.0</log4j2.version>
43+
<slf4j.version>1.7.32</slf4j.version>
4444
</properties>
4545

4646
<repositories>
@@ -133,14 +133,14 @@
133133

134134
<dependencies>
135135
<dependency>
136-
<groupId>org.apache.logging.log4j</groupId>
137-
<artifactId>log4j-api</artifactId>
138-
<version>${log4j2.version}</version>
136+
<groupId>org.slf4j</groupId>
137+
<artifactId>slf4j-api</artifactId>
138+
<version>${slf4j.version}</version>
139139
</dependency>
140140
<dependency>
141-
<groupId>org.apache.logging.log4j</groupId>
142-
<artifactId>log4j-core</artifactId>
143-
<version>${log4j2.version}</version>
141+
<groupId>org.slf4j</groupId>
142+
<artifactId>slf4j-jdk14</artifactId>
143+
<version>${slf4j.version}</version>
144144
<scope>runtime</scope>
145145
</dependency>
146146

dataflow/flex-templates/streaming_beam_sql/src/main/java/org/apache/beam/samples/StreamingBeamSql.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@
4242
import org.apache.beam.sdk.transforms.windowing.Window;
4343
import org.apache.beam.sdk.values.Row;
4444
import org.apache.beam.sdk.values.TypeDescriptor;
45-
import org.apache.logging.log4j.LogManager;
46-
import org.apache.logging.log4j.Logger;
4745
import org.joda.time.Duration;
4846
import org.joda.time.Instant;
47+
import org.slf4j.Logger;
48+
import org.slf4j.LoggerFactory;
4949

5050
/**
5151
* An Apache Beam streaming pipeline that reads JSON encoded messages fromPub/Sub,
5252
* uses Beam SQL to transform the message data, and writes the results to a BigQuery.
5353
*/
5454
public class StreamingBeamSql {
55-
private static final Logger LOG = LogManager.getLogger(StreamingBeamSql.class);
55+
private static final Logger LOG = LoggerFactory.getLogger(StreamingBeamSql.class);
5656
private static final Gson GSON = new Gson();
5757

5858
public interface Options extends StreamingOptions {

dataflow/spanner-io/pom.xml

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
</parent>
3535

3636
<properties>
37+
<maven.compiler.source>11</maven.compiler.source>
38+
<maven.compiler.target>11</maven.compiler.target>
3739
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38-
<java.version>1.8</java.version>
39-
<maven.compiler.source>1.8</maven.compiler.source>
40-
<maven.compiler.target>1.8</maven.compiler.target>
41-
<apache_beam.version>2.31.0</apache_beam.version>
42-
<log4j2.version>2.17.0</log4j2.version>
40+
41+
<apache_beam.version>2.33.0</apache_beam.version>
42+
<slf4j.version>1.7.32</slf4j.version>
4343
</properties>
4444

4545
<build>
@@ -102,14 +102,14 @@
102102

103103
<!-- Misc -->
104104
<dependency>
105-
<groupId>org.apache.logging.log4j</groupId>
106-
<artifactId>log4j-api</artifactId>
107-
<version>${log4j2.version}</version>
105+
<groupId>org.slf4j</groupId>
106+
<artifactId>slf4j-api</artifactId>
107+
<version>${slf4j.version}</version>
108108
</dependency>
109109
<dependency>
110-
<groupId>org.apache.logging.log4j</groupId>
111-
<artifactId>log4j-core</artifactId>
112-
<version>${log4j2.version}</version>
110+
<groupId>org.slf4j</groupId>
111+
<artifactId>slf4j-jdk14</artifactId>
112+
<version>${slf4j.version}</version>
113113
<scope>runtime</scope>
114114
</dependency>
115115

dataflow/spanner-io/src/main/java/com/example/dataflow/SpannerWrite.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.apache.beam.sdk.transforms.DoFn;
3030
import org.apache.beam.sdk.transforms.ParDo;
3131
import org.apache.beam.sdk.values.PCollection;
32-
import org.apache.logging.log4j.LogManager;
33-
import org.apache.logging.log4j.Logger;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3434

3535
/*
3636
This sample demonstrates how to write to a Spanner table.
@@ -125,10 +125,10 @@ static class Album {
125125

126126
/**
127127
* Parses each tab-delimited line into a Singer object. The line format is the following:
128-
* singer_id\tfirstName\tlastName
128+
* singer_id\tfirstName\tlastName
129129
*/
130130
static class ParseSinger extends DoFn<String, Singer> {
131-
private static final Logger LOG = LogManager.getLogger(ParseSinger.class);
131+
private static final Logger LOG = LoggerFactory.getLogger(ParseSinger.class);
132132

133133
@ProcessElement
134134
public void processElement(ProcessContext c) {
@@ -146,10 +146,10 @@ public void processElement(ProcessContext c) {
146146

147147
/**
148148
* Parses each tab-delimited line into an Album object. The line format is the following:
149-
* singer_id\talbumId\talbumTitle
149+
* singer_id\talbumId\talbumTitle
150150
*/
151151
static class ParseAlbum extends DoFn<String, Album> {
152-
private static final Logger LOG = LogManager.getLogger(ParseAlbum.class);
152+
private static final Logger LOG = LoggerFactory.getLogger(ParseAlbum.class);
153153

154154
@ProcessElement
155155
public void processElement(ProcessContext c) {

dataflow/templates/pom.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<maven-exec-plugin.version>3.0.0</maven-exec-plugin.version>
4141
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
4242
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
43-
<log4j2.version>2.17.0</log4j2.version>
43+
<slf4j.version>1.7.32</slf4j.version>
4444
</properties>
4545

4646
<repositories>
@@ -132,14 +132,14 @@
132132

133133
<dependencies>
134134
<dependency>
135-
<groupId>org.apache.logging.log4j</groupId>
136-
<artifactId>log4j-api</artifactId>
137-
<version>${log4j2.version}</version>
135+
<groupId>org.slf4j</groupId>
136+
<artifactId>slf4j-api</artifactId>
137+
<version>${slf4j.version}</version>
138138
</dependency>
139139
<dependency>
140-
<groupId>org.apache.logging.log4j</groupId>
141-
<artifactId>log4j-core</artifactId>
142-
<version>${log4j2.version}</version>
140+
<groupId>org.slf4j</groupId>
141+
<artifactId>slf4j-jdk14</artifactId>
142+
<version>${slf4j.version}</version>
143143
<scope>runtime</scope>
144144
</dependency>
145145

0 commit comments

Comments
 (0)