diff --git a/fizz-bootstrap/pom.xml b/fizz-bootstrap/pom.xml
index 21ea75c..46f1cae 100644
--- a/fizz-bootstrap/pom.xml
+++ b/fizz-bootstrap/pom.xml
@@ -20,7 +20,7 @@
Dragonfruit-SR3
Dysprosium-SR25
5.3.7.RELEASE
- 4.1.77.Final
+ 4.1.78.Final
4.4.15
2.17.2
1.7.36
@@ -34,7 +34,7 @@
1.15
2.11.1
2.8.9
- 2.0.52.Final
+ 2.0.53.Final
2.2.9.RELEASE
1.30
@@ -80,6 +80,18 @@
netty-tcnative-classes
${netty-tcnative.version}
+
+
+ org.apache.logging.log4j
+ log4j-layout-template-json
+ ${log4j2.version}
+
+
+
+ org.apache.kafka
+ kafka-clients
+ 2.0.1
+
diff --git a/fizz-bootstrap/src/main/java/we/FizzBootstrapApplication.java b/fizz-bootstrap/src/main/java/we/FizzBootstrapApplication.java
index e54ab0c..74ed6e7 100644
--- a/fizz-bootstrap/src/main/java/we/FizzBootstrapApplication.java
+++ b/fizz-bootstrap/src/main/java/we/FizzBootstrapApplication.java
@@ -85,6 +85,7 @@ import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWeb
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import we.config.AggregateRedisConfig;
import we.log.LogSendAppender;
+import we.util.FileUtils;
/**
* fizz gateway application boot entrance
@@ -186,8 +187,13 @@ public class FizzBootstrapApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(FizzBootstrapApplication.class);
public static void main(String[] args) {
- System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
- System.setProperty("log4j2.formatMsgNoLookups", "true");
+ System.setProperty("log4j2.contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
+ System.setProperty("log4j2.formatMsgNoLookups", "true");
+ System.setProperty("log4j2.isThreadContextMapInheritable", "true");
+
+ String appRootDir = FileUtils.getAppRootDir();
+ System.setProperty("APP_ROOT_DIR", appRootDir);
+ LOGGER.info("app root dir: {}", appRootDir);
SpringApplication springApplication = new SpringApplication(FizzBootstrapApplication.class);
springApplication.setApplicationContextClass(CustomReactiveWebServerApplicationContext.class);
diff --git a/fizz-bootstrap/src/main/resources/log4j2-kafka.json b/fizz-bootstrap/src/main/resources/log4j2-kafka.json
new file mode 100644
index 0000000..c540015
--- /dev/null
+++ b/fizz-bootstrap/src/main/resources/log4j2-kafka.json
@@ -0,0 +1,38 @@
+{
+ "logTime": {
+ "$resolver": "timestamp",
+ "epoch": {
+ "unit": "millis",
+ "rounded": true
+ }
+ },
+ "logLevel": {
+ "$resolver": "level",
+ "field": "name"
+ },
+ "logMsg": {
+ "$resolver": "message",
+ "stringified": true
+ },
+ "thread": {
+ "$resolver": "thread",
+ "field": "name"
+ },
+ "loggerName": {
+ "$resolver": "logger",
+ "field": "name"
+ },
+ "thrown": {
+ "message": {
+ "$resolver": "exception",
+ "field": "message"
+ },
+ "extendedStackTrace": {
+ "$resolver": "exception",
+ "field": "stackTrace",
+ "stackTrace": {
+ "stringified": true
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/fizz-bootstrap/src/main/resources/log4j2-spring.xml b/fizz-bootstrap/src/main/resources/log4j2-spring.xml
index b948186..e904fe5 100644
--- a/fizz-bootstrap/src/main/resources/log4j2-spring.xml
+++ b/fizz-bootstrap/src/main/resources/log4j2-spring.xml
@@ -2,24 +2,76 @@
- ${sys:APP_NAME}
+ fizz-bootstrap
+ ${sys:APP_ROOT_DIR}/log
+
+
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fizz-bootstrap/src/main/resources/log4j2.component.properties b/fizz-bootstrap/src/main/resources/log4j2.component.properties
new file mode 100644
index 0000000..e0c714f
--- /dev/null
+++ b/fizz-bootstrap/src/main/resources/log4j2.component.properties
@@ -0,0 +1,2 @@
+log4j2.asyncQueueFullPolicy=Discard
+log4j2.discardThreshold=ERROR
\ No newline at end of file
diff --git a/fizz-bootstrap/src/test/resource/log4j2-test.xml b/fizz-bootstrap/src/test/resource/log4j2-test.xml
index e43c021..14f26f5 100644
--- a/fizz-bootstrap/src/test/resource/log4j2-test.xml
+++ b/fizz-bootstrap/src/test/resource/log4j2-test.xml
@@ -1,17 +1,14 @@
-
- fizz-gateway
-
-
+
-
+
diff --git a/fizz-common/pom.xml b/fizz-common/pom.xml
index 91ad0e9..6ef21ec 100644
--- a/fizz-common/pom.xml
+++ b/fizz-common/pom.xml
@@ -17,6 +17,16 @@
+
+ org.apache.logging.log4j
+ log4j-layout-template-json
+
+
+
+ org.apache.kafka
+ kafka-clients
+
+
org.openjdk.jol
jol-core
diff --git a/fizz-common/src/main/java/we/flume/clients/log4j2appender/LogService.java b/fizz-common/src/main/java/we/flume/clients/log4j2appender/LogService.java
index 8294458..11179b6 100644
--- a/fizz-common/src/main/java/we/flume/clients/log4j2appender/LogService.java
+++ b/fizz-common/src/main/java/we/flume/clients/log4j2appender/LogService.java
@@ -17,24 +17,29 @@
package we.flume.clients.log4j2appender;
+import org.apache.logging.log4j.ThreadContext;
import we.constants.CommonConstants;
+import we.util.Consts;
public enum LogService {
BIZ_ID, HANDLE_STGY, APP;
public static void cleanBizId() {
- setBizId(null);
+ // setBizId(null);
+ ThreadContext.remove(Consts.TRACE_ID);
}
public static Object getBizId() {
- return ThreadContext.get(Constants.BIZ_ID);
+ // return ThreadContext.get(Constants.BIZ_ID);
+ return ThreadContext.get(Consts.TRACE_ID);
}
public static void setBizId(Object bizId) {
- ThreadContext.set(Constants.BIZ_ID, bizId);
+ // ThreadContext.set(Constants.BIZ_ID, bizId);
if (bizId != null) {
- org.apache.logging.log4j.ThreadContext.put(CommonConstants.TRACE_ID, String.valueOf(bizId));
+ // org.apache.logging.log4j.ThreadContext.put(CommonConstants.TRACE_ID, String.valueOf(bizId));
+ ThreadContext.put(Consts.TRACE_ID, String.valueOf(bizId));
}
}
@@ -45,7 +50,7 @@ public enum LogService {
public static String toESaKF(String topic) {
return Constants.AND + topic;
}
-
+
public static class Constants {
static final String BIZ_ID = "bizId";
static final char AND = '&';
diff --git a/fizz-common/src/main/java/we/flume/clients/log4j2appender/ThreadContext.java b/fizz-common/src/main/java/we/flume/clients/log4j2appender/ThreadContext.java
index f3f1bba..fbceff1 100644
--- a/fizz-common/src/main/java/we/flume/clients/log4j2appender/ThreadContext.java
+++ b/fizz-common/src/main/java/we/flume/clients/log4j2appender/ThreadContext.java
@@ -1,90 +1,90 @@
-/*
- * Copyright (C) 2020 the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package we.flume.clients.log4j2appender;
-
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-/** for internal use */
-public abstract class ThreadContext {
-
- private static ThreadLocal