Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.
Merged
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
5 changes: 5 additions & 0 deletions browsermob-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>log4j2-ecs-layout</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
import net.lightbody.bmp.proxy.CaptureType;
import net.lightbody.bmp.util.BeansJsonMapper;
import net.lightbody.bmp.util.BrowserMobHttpUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.message.StringMapMessage;
import org.littleshoot.proxy.impl.ProxyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.net.InetAddress;
import java.net.InetSocketAddress;
Expand All @@ -57,7 +58,7 @@
import static net.lightbody.bmp.filters.StatsDMetricsFilter.prepareMetric;

public class HarCaptureFilter extends HttpsAwareFiltersAdapter {
private static final Logger log = LoggerFactory.getLogger(HarCaptureFilter.class);
private static final Logger log = LogManager.getLogger();
private static final InheritableThreadLocal<HarRequest> isAlreadyLoggedIn = new InheritableThreadLocal<>();

/**
Expand Down Expand Up @@ -796,14 +797,16 @@ protected static void logFailedRequestIfRequired(HarRequest request, HarResponse
if ((Objects.isNull(isAlreadyLoggedIn.get()) ||
isAlreadyLoggedIn.get().hashCode() != request.hashCode())
&& (response.getStatus() >= 500 || response.getStatus() == 0)) {
MDC.put("caller", "mobproxy");
MDC.put("http_response_code", String.valueOf(response.getStatus()));
MDC.put("http_host", request.getUrl());
MDC.put("request_details", BeansJsonMapper.getJsonString(request));
MDC.put("method", request.getMethod());
MDC.put("response", BeansJsonMapper.getJsonString(response));
log.error("received bad status code");
log.error(new StringMapMessage()
.with("message", "received bad status code")
.with("caller", "mobproxy")
.with("http_response_code", String.valueOf(response.getStatus()))
.with("http_host", request.getUrl())
.with("request_details", BeansJsonMapper.getJsonString(request))
.with("method", request.getMethod())
.with("response", BeansJsonMapper.getJsonString(response)));
isAlreadyLoggedIn.set(request);
ThreadContext.clearMap();
}
}

Expand Down
5 changes: 5 additions & 0 deletions browsermob-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
<artifactId>logstash-gelf</artifactId>
</dependency>

<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>log4j2-ecs-layout</artifactId>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@
<version>${logstash-gelf.version}</version>
</dependency>

<dependency>
<groupId>co.elastic.logging</groupId>
<artifactId>log4j2-ecs-layout</artifactId>
<version>0.5.0</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
Expand Down