[HUDI-1176] Upgrade hudi to log4j2 (#5366)
* Move to log4j2 cr: https://code.amazon.com/reviews/CR-71010705 * Upgrade unit tests to log4j2 * update exclusion Co-authored-by: Brandon Scheller <bschelle@amazon.com>
This commit is contained in:
@@ -48,8 +48,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Hadoop -->
|
<!-- Hadoop -->
|
||||||
|
|||||||
@@ -201,8 +201,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -55,8 +55,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Parquet -->
|
<!-- Parquet -->
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.hudi.config.HoodieWriteCommitCallbackConfig;
|
import org.apache.hudi.config.HoodieWriteCommitCallbackConfig;
|
||||||
import org.apache.hudi.config.HoodieWriteConfig;
|
import org.apache.hudi.config.HoodieWriteConfig;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import org.apache.http.entity.ContentType;
|
|||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.fasterxml.jackson.databind.node.TextNode;
|
import com.fasterxml.jackson.databind.node.TextNode;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ import org.apache.hudi.callback.client.http.HoodieWriteCommitHttpCallbackClient;
|
|||||||
import org.apache.http.StatusLine;
|
import org.apache.http.StatusLine;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.log4j.AppenderSkeleton;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.core.Appender;
|
||||||
import org.apache.log4j.spi.LoggingEvent;
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
|
import org.apache.logging.log4j.core.Logger;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
@@ -52,10 +54,10 @@ import static org.mockito.Mockito.when;
|
|||||||
public class TestCallbackHttpClient {
|
public class TestCallbackHttpClient {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
AppenderSkeleton appender;
|
Appender appender;
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
ArgumentCaptor<LoggingEvent> logCaptor;
|
ArgumentCaptor<LogEvent> logCaptor;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
CloseableHttpClient httpClient;
|
CloseableHttpClient httpClient;
|
||||||
@@ -66,8 +68,17 @@ public class TestCallbackHttpClient {
|
|||||||
@Mock
|
@Mock
|
||||||
StatusLine statusLine;
|
StatusLine statusLine;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void prepareAppender() {
|
||||||
|
when(appender.getName()).thenReturn("MockAppender");
|
||||||
|
when(appender.isStarted()).thenReturn(true);
|
||||||
|
when(appender.isStopped()).thenReturn(false);
|
||||||
|
((Logger) LogManager.getLogger(HoodieWriteCommitHttpCallbackClient.class)).addAppender(appender);
|
||||||
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void resetMocks() {
|
void resetMocks() {
|
||||||
|
((Logger) LogManager.getLogger(HoodieWriteCommitHttpCallbackClient.class)).removeAppender(appender);
|
||||||
reset(appender, httpClient, httpResponse, statusLine);
|
reset(appender, httpClient, httpResponse, statusLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,21 +94,19 @@ public class TestCallbackHttpClient {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogWhenRequestFailed() throws IOException {
|
public void sendPayloadShouldLogWhenRequestFailed() throws IOException {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
|
||||||
when(httpClient.execute(any())).thenThrow(IOException.class);
|
when(httpClient.execute(any())).thenThrow(IOException.class);
|
||||||
|
|
||||||
HoodieWriteCommitHttpCallbackClient hoodieWriteCommitCallBackHttpClient =
|
HoodieWriteCommitHttpCallbackClient hoodieWriteCommitCallBackHttpClient =
|
||||||
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
||||||
hoodieWriteCommitCallBackHttpClient.send("{}");
|
hoodieWriteCommitCallBackHttpClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertEquals("Failed to send callback.", logCaptor.getValue().getRenderedMessage());
|
assertEquals("Failed to send callback.", logCaptor.getValue().getMessage().getFormattedMessage());
|
||||||
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogUnsuccessfulSending() {
|
public void sendPayloadShouldLogUnsuccessfulSending() {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
|
||||||
mockResponse(401);
|
mockResponse(401);
|
||||||
when(httpResponse.toString()).thenReturn("unauthorized");
|
when(httpResponse.toString()).thenReturn("unauthorized");
|
||||||
|
|
||||||
@@ -105,22 +114,21 @@ public class TestCallbackHttpClient {
|
|||||||
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
||||||
hoodieWriteCommitCallBackHttpClient.send("{}");
|
hoodieWriteCommitCallBackHttpClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertEquals("Failed to send callback message. Response was unauthorized", logCaptor.getValue().getRenderedMessage());
|
assertEquals("Failed to send callback message. Response was unauthorized", logCaptor.getValue().getMessage().getFormattedMessage());
|
||||||
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogSuccessfulSending() {
|
public void sendPayloadShouldLogSuccessfulSending() {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
|
||||||
mockResponse(202);
|
mockResponse(202);
|
||||||
|
|
||||||
HoodieWriteCommitHttpCallbackClient hoodieWriteCommitCallBackHttpClient =
|
HoodieWriteCommitHttpCallbackClient hoodieWriteCommitCallBackHttpClient =
|
||||||
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
new HoodieWriteCommitHttpCallbackClient("fake_api_key", "fake_url", httpClient);
|
||||||
hoodieWriteCommitCallBackHttpClient.send("{}");
|
hoodieWriteCommitCallBackHttpClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertTrue(logCaptor.getValue().getRenderedMessage().startsWith("Sent Callback data"));
|
assertTrue(logCaptor.getValue().getMessage().getFormattedMessage().startsWith("Sent Callback data"));
|
||||||
assertEquals(Level.INFO, logCaptor.getValue().getLevel());
|
assertEquals(Level.INFO, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ import org.apache.hudi.metrics.datadog.DatadogHttpClient.ApiSite;
|
|||||||
import org.apache.http.StatusLine;
|
import org.apache.http.StatusLine;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.log4j.AppenderSkeleton;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.core.Appender;
|
||||||
import org.apache.log4j.spi.LoggingEvent;
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
|
import org.apache.logging.log4j.core.Logger;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
@@ -55,10 +57,10 @@ import static org.mockito.Mockito.when;
|
|||||||
public class TestDatadogHttpClient {
|
public class TestDatadogHttpClient {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
AppenderSkeleton appender;
|
Appender appender;
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
ArgumentCaptor<LoggingEvent> logCaptor;
|
ArgumentCaptor<LogEvent> logCaptor;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
CloseableHttpClient httpClient;
|
CloseableHttpClient httpClient;
|
||||||
@@ -69,8 +71,17 @@ public class TestDatadogHttpClient {
|
|||||||
@Mock
|
@Mock
|
||||||
StatusLine statusLine;
|
StatusLine statusLine;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void prepareAppender() {
|
||||||
|
when(appender.getName()).thenReturn("MockAppender");
|
||||||
|
when(appender.isStarted()).thenReturn(true);
|
||||||
|
when(appender.isStopped()).thenReturn(false);
|
||||||
|
((Logger) LogManager.getLogger(DatadogHttpClient.class)).addAppender(appender);
|
||||||
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void resetMocks() {
|
void resetMocks() {
|
||||||
|
((org.apache.logging.log4j.core.Logger) LogManager.getLogger(DatadogHttpClient.class)).removeAppender(appender);
|
||||||
reset(appender, httpClient, httpResponse, statusLine);
|
reset(appender, httpClient, httpResponse, statusLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,41 +117,41 @@ public class TestDatadogHttpClient {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogWhenRequestFailed() throws IOException {
|
public void sendPayloadShouldLogWhenRequestFailed() throws IOException {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
((Logger) LogManager.getLogger(DatadogHttpClient.class)).addAppender(appender);
|
||||||
when(httpClient.execute(any())).thenThrow(IOException.class);
|
when(httpClient.execute(any())).thenThrow(IOException.class);
|
||||||
|
|
||||||
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
||||||
ddClient.send("{}");
|
ddClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertEquals("Failed to send to Datadog.", logCaptor.getValue().getRenderedMessage());
|
assertEquals("Failed to send to Datadog.", logCaptor.getValue().getMessage().getFormattedMessage());
|
||||||
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogUnsuccessfulSending() {
|
public void sendPayloadShouldLogUnsuccessfulSending() {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
((Logger) LogManager.getLogger(DatadogHttpClient.class)).addAppender(appender);
|
||||||
mockResponse(401);
|
mockResponse(401);
|
||||||
when(httpResponse.toString()).thenReturn("unauthorized");
|
when(httpResponse.toString()).thenReturn("unauthorized");
|
||||||
|
|
||||||
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
||||||
ddClient.send("{}");
|
ddClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertEquals("Failed to send to Datadog. Response was unauthorized", logCaptor.getValue().getRenderedMessage());
|
assertEquals("Failed to send to Datadog. Response was unauthorized", logCaptor.getValue().getMessage().getFormattedMessage());
|
||||||
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendPayloadShouldLogSuccessfulSending() {
|
public void sendPayloadShouldLogSuccessfulSending() {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
((Logger) LogManager.getLogger(DatadogHttpClient.class)).addAppender(appender);
|
||||||
mockResponse(202);
|
mockResponse(202);
|
||||||
|
|
||||||
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
DatadogHttpClient ddClient = new DatadogHttpClient(ApiSite.US, "foo", true, httpClient);
|
||||||
ddClient.send("{}");
|
ddClient.send("{}");
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertTrue(logCaptor.getValue().getRenderedMessage().startsWith("Sent metrics data"));
|
assertTrue(logCaptor.getValue().getMessage().getFormattedMessage().startsWith("Sent metrics data"));
|
||||||
assertEquals(Level.DEBUG, logCaptor.getValue().getLevel());
|
assertEquals(Level.DEBUG, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,11 @@ import org.apache.hudi.metrics.datadog.DatadogReporter.PayloadBuilder;
|
|||||||
|
|
||||||
import com.codahale.metrics.MetricFilter;
|
import com.codahale.metrics.MetricFilter;
|
||||||
import com.codahale.metrics.MetricRegistry;
|
import com.codahale.metrics.MetricRegistry;
|
||||||
import org.apache.log4j.AppenderSkeleton;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.logging.log4j.core.Appender;
|
||||||
import org.apache.log4j.spi.LoggingEvent;
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
|
import org.apache.logging.log4j.core.Logger;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
@@ -44,15 +45,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class TestDatadogReporter {
|
public class TestDatadogReporter {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
AppenderSkeleton appender;
|
Appender appender;
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
ArgumentCaptor<LoggingEvent> logCaptor;
|
ArgumentCaptor<LogEvent> logCaptor;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
MetricRegistry registry;
|
MetricRegistry registry;
|
||||||
@@ -62,6 +64,7 @@ public class TestDatadogReporter {
|
|||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void resetMocks() {
|
void resetMocks() {
|
||||||
|
((Logger) LogManager.getLogger(DatadogReporter.class)).removeAppender(appender);
|
||||||
reset(appender, registry, client);
|
reset(appender, registry, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,14 +78,18 @@ public class TestDatadogReporter {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void stopShouldLogWhenEnclosedClientFailToClose() throws IOException {
|
public void stopShouldLogWhenEnclosedClientFailToClose() throws IOException {
|
||||||
Logger.getRootLogger().addAppender(appender);
|
when(appender.getName()).thenReturn("MockAppender");
|
||||||
|
when(appender.isStarted()).thenReturn(true);
|
||||||
|
when(appender.isStopped()).thenReturn(false);
|
||||||
|
((Logger) LogManager.getLogger(DatadogReporter.class)).addAppender(appender);
|
||||||
|
|
||||||
doThrow(IOException.class).when(client).close();
|
doThrow(IOException.class).when(client).close();
|
||||||
|
|
||||||
new DatadogReporter(registry, client, "foo", Option.empty(), Option.empty(),
|
new DatadogReporter(registry, client, "foo", Option.empty(), Option.empty(),
|
||||||
MetricFilter.ALL, TimeUnit.SECONDS, TimeUnit.SECONDS).stop();
|
MetricFilter.ALL, TimeUnit.SECONDS, TimeUnit.SECONDS).stop();
|
||||||
|
|
||||||
verify(appender).doAppend(logCaptor.capture());
|
verify(appender).append(logCaptor.capture());
|
||||||
assertEquals("Error disconnecting from Datadog.", logCaptor.getValue().getRenderedMessage());
|
assertEquals("Error disconnecting from Datadog.", logCaptor.getValue().getMessage().getFormattedMessage());
|
||||||
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
assertEquals(Level.WARN, logCaptor.getValue().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,16 @@ See https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -165,8 +165,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -171,8 +171,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Fasterxml -->
|
<!-- Fasterxml -->
|
||||||
|
|||||||
@@ -256,8 +256,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Fasterxml -->
|
<!-- Fasterxml -->
|
||||||
|
|||||||
@@ -98,8 +98,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -70,8 +70,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -55,8 +55,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -77,8 +77,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Fasterxml -->
|
<!-- Fasterxml -->
|
||||||
|
|||||||
@@ -173,8 +173,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -644,8 +644,16 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
|||||||
@@ -284,8 +284,16 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|||||||
@@ -44,8 +44,16 @@
|
|||||||
|
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Fasterxml -->
|
<!-- Fasterxml -->
|
||||||
|
|||||||
18
pom.xml
18
pom.xml
@@ -106,8 +106,8 @@
|
|||||||
<junit.vintage.version>5.7.2</junit.vintage.version>
|
<junit.vintage.version>5.7.2</junit.vintage.version>
|
||||||
<junit.platform.version>1.7.2</junit.platform.version>
|
<junit.platform.version>1.7.2</junit.platform.version>
|
||||||
<mockito.jupiter.version>3.3.3</mockito.jupiter.version>
|
<mockito.jupiter.version>3.3.3</mockito.jupiter.version>
|
||||||
<log4j.version>1.2.17</log4j.version>
|
|
||||||
<log4j.test.version>2.17.2</log4j.test.version>
|
<log4j.test.version>2.17.2</log4j.test.version>
|
||||||
|
<log4j2.version>2.17.2</log4j2.version>
|
||||||
<slf4j.version>1.7.30</slf4j.version>
|
<slf4j.version>1.7.30</slf4j.version>
|
||||||
<joda.version>2.9.9</joda.version>
|
<joda.version>2.9.9</joda.version>
|
||||||
<hadoop.version>2.10.1</hadoop.version>
|
<hadoop.version>2.10.1</hadoop.version>
|
||||||
@@ -512,9 +512,19 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Logging -->
|
<!-- Logging -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>${log4j.version}</version>
|
<version>${log4j2.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>${log4j2.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-1.2-api</artifactId>
|
||||||
|
<version>${log4j2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Fasterxml -->
|
<!-- Fasterxml -->
|
||||||
|
|||||||
Reference in New Issue
Block a user