zyx 2 năm trước cách đây
mục cha
commit
8b3d43b20c

+ 10 - 1
src/main/java/com/sxtvs/open/core/sls/AliyunLogger.java

@@ -9,6 +9,8 @@ import com.aliyun.openservices.log.common.LogItem;
 import com.sxtvs.open.core.auth.HttpContextUtil;
 import jakarta.annotation.PostConstruct;
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.io.PrintWriter;
@@ -16,17 +18,24 @@ import java.io.StringWriter;
 import java.util.Map;
 
 @Component
+@Slf4j
 public class AliyunLogger {
     private Producer producer;
-    private final String logStore = "java-log";
+    private String logStore = "java-log";
     private final String project = "k8s-log-c4d23a31b8c6c4ed49e7fc1473dfd0c57";
 
     private final String app = "open";
 
+    @Value("${sls.enable}")
+    private boolean enable;
+
 
     @PostConstruct
     public void init() {
 
+        if (!enable) {
+            logStore = "java-log-dev";
+        }
         ProducerConfig producerConfig = new ProducerConfig();
         producerConfig.setBatchSizeThresholdInBytes(3 * 1024 * 1024);
         producerConfig.setBatchCountThreshold(40960);

+ 3 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,3 @@
+
+sls:
+  enable: false

+ 2 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,2 @@
+sls:
+  enable: false

+ 2 - 0
src/main/resources/application.yml

@@ -53,6 +53,8 @@ spring:
   jackson:
     time-zone: GMT+8
     date-format: "yyyy-MM-dd HH:mm:ss"
+  profiles:
+    default: dev
 
 server:
   port: 80