Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Change logging implementation to Log4j 2. #1533

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion api-consumption/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.json:json:20180130'

compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'

// open tracing
compile "io.opentracing:opentracing-api:$opentracingVersion"
Expand Down
2 changes: 1 addition & 1 deletion api-cursors/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.json:json:20180130'

compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'

// open tracing
compile "io.opentracing:opentracing-api:$opentracingVersion"
Expand Down
2 changes: 1 addition & 1 deletion api-misc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.json:json:20180130'

compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'

// open tracing
compile "io.opentracing:opentracing-api:$opentracingVersion"
Expand Down
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.zalando:problem-spring-web:0.23.0'
compile 'com.google.guava:guava:30.1-jre'
compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'
compile 'org.apache.logging.log4j:log4j-core'
compile 'org.apache.logging.log4j:log4j-slf4j-impl'

compile "io.dropwizard.metrics:metrics-core:$dropwizardVersion"
compile("com.ryantenney.metrics:metrics-spring:$dropwizardVersion") {
exclude module: 'spring-core'
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/org/zalando/nakadi/config/NakadiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


import com.google.common.collect.Lists;
import org.apache.log4j.NDC;
import org.slf4j.MDC;
import org.apache.logging.log4j.ThreadContext;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -39,8 +38,7 @@ public Runnable decorate(final Runnable runnable) {
return new Runnable() {
@Override
public void run() {
NDC.clear();
MDC.clear();
ThreadContext.clearAll();

runnable.run();
}
Expand Down

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/resources/log4j.properties

This file was deleted.

46 changes: 46 additions & 0 deletions app/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="10">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSSXXX}] [%p] [%X{flowId}] [%t] [%c] --- %m %throwable{2}%n</pattern>
</PatternLayout>
</Console>
<Console name="ConsoleSubscription" target="SYSTEM_OUT">
<PatternLayout>
<pattern>[%d{yyyy-MM-dd HH:mm:ss.SSSXXX}] [%p] [%X{flowId},%X{subscriptionId},%X{streamId}] [%t] [%c] --- %m %throwable{2}%n</pattern>
</PatternLayout>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
<Logger name="org.apache.catalina.startup.DigesterFactory" level="error" additivity="false"/>
<Logger name="org.apache.catalina.util.LifecycleBase" level="error" additivity="false"/>
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" additivity="false"/>
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" additivity="false"/>
<Logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="error" additivity="false"/>
<Logger name="org.hibernate.validator.internal.util.Version" level="warn" additivity="false"/>
<Logger name="org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration" level="warn" additivity="false"/>
<Logger name="org.springframework.boot.actuate.endpoint.jmx" level="warn" additivity="false"/>
<Logger name="org.zalando.nakadi" level="info" additivity="false"/>
<Logger name="org.zalando.nakadi.config" level="info" additivity="false"/>
<Logger name="org.apache.kafka" level="warn" additivity="false"/>
<Logger name="org.zalando.nakadi.service.ClosedConnectionsCrutch" level="warn" additivity="false"/>
<Logger name="org.zalando.nakadi.repository.kafka.KafkaFactory$KafkaCrutchConsumer" level="warn" additivity="false"/>

<!-- Subscription logging part -->
<Logger name="org.zalando.nakadi.service.subscription" level="debug" additivity="false">
<filters>
<!-- Log all above INFO level -->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<!-- Otherwise, log more only if `subscriptionId` MDC is one of listed here -->
<ThreadContextMapFilter operator="or" onMatch="NEUTRAL" onMismatch="DENY">
<KeyValuePair key="subscriptionId" value="00000000-0000-0000-0000-000000000000"/>
</ThreadContextMapFilter>
</filters>
<AppenderRef ref="ConsoleSubscription"/>
</Logger>
</Loggers>
</Configuration>
2 changes: 1 addition & 1 deletion core-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ dependencies {
compile 'com.github.luben:zstd-jni:1.5.2-2'

// tests
testCompile 'org.slf4j:slf4j-log4j12'
testCompile 'org.apache.logging.log4j:log4j-slf4j-impl'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile("org.springframework.boot:spring-boot-starter-validation")
testCompile('org.junit.jupiter:junit-jupiter:5.7.2') {
Expand Down
25 changes: 0 additions & 25 deletions core-common/src/test/resources/log4j.properties

This file was deleted.

2 changes: 1 addition & 1 deletion core-metastore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.json:json:20180130'

compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'

// open tracing
compile "io.opentracing:opentracing-api:$opentracingVersion"
Expand Down
2 changes: 1 addition & 1 deletion core-services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
compile 'org.zalando:problem:0.22.0'
compile 'org.json:json:20180130'

compile 'org.slf4j:slf4j-log4j12'
compile 'org.slf4j:slf4j-api'

// open tracing
compile "io.opentracing:opentracing-api:$opentracingVersion"
Expand Down
25 changes: 0 additions & 25 deletions core-services/src/test/resources/log4j.properties

This file was deleted.