Skip to content

Commit e3bf9d1

Browse files
committed
SF-4325 - updating to use APMLog by default for trace info - fallback on existing methods.
1 parent bc07105 commit e3bf9d1

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
.project
33
.settings
44
target
5-
coverage.ec
5+
coverage.ec
6+
.idea
7+
*.iml

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>com.stackify</groupId>
6464
<artifactId>stackify-api-java</artifactId>
65-
<version>2.1.6</version>
65+
<version>2.1.8-SNAPSHOT</version>
6666
</dependency>
6767

6868
<!-- Runtime dependencies -->

src/main/java/com/stackify/log/log4j12/LoggingEventAdapter.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Iterator;
2121
import java.util.Map;
2222

23+
import com.stackify.api.common.log.APMLogData;
2324
import org.apache.log4j.Level;
2425
import org.apache.log4j.spi.LocationInfo;
2526
import org.apache.log4j.spi.LoggingEvent;
@@ -119,14 +120,14 @@ public StackifyError getStackifyError(final LoggingEvent event, final Throwable
119120

120121
builder.error(Throwables.toErrorItem(getMessage(event), className, methodName, lineNumber));
121122
}
122-
123-
String user = ServletLogContext.getUser();
124-
123+
124+
String user = APMLogData.isLinked() ? APMLogData.getUser() : ServletLogContext.getUser();
125+
125126
if (user != null) {
126127
builder.userName(user);
127128
}
128-
129-
WebRequestDetail webRequest = ServletLogContext.getWebRequest();
129+
130+
WebRequestDetail webRequest = APMLogData.isLinked() ? APMLogData.getWebRequest() : ServletLogContext.getWebRequest();
130131

131132
if (webRequest != null) {
132133
builder.webRequestDetail(webRequest);
@@ -162,7 +163,7 @@ public LogMsg getLogMsg(final LoggingEvent event, final StackifyError error) {
162163
builder.epochMs(event.getTimeStamp());
163164
builder.level(event.getLevel().toString().toLowerCase());
164165

165-
String transactionId = ServletLogContext.getTransactionId();
166+
String transactionId = APMLogData.isLinked() ? APMLogData.getTransactionId() : ServletLogContext.getTransactionId();
166167

167168
if (transactionId != null) {
168169
builder.transId(transactionId);

0 commit comments

Comments
 (0)