Parcourir la source

日志配置,暂时都为test中

刘立冬 il y a 2 mois
Parent
commit
8f675b2352

+ 2 - 2
risk-control-server/src/main/resources/application-dev.yml

@@ -31,7 +31,7 @@ app:
   id: risk-control
 apollo:
   bootstrap:
-    enabled: true
+    enabled: false
     namespaces: application
   meta: http://devapolloconfig-internal.piaoquantv.com
   cacheDir: /datalog/apollo-cache-dir
@@ -41,7 +41,7 @@ aliyun:
     endpoint: cn-hangzhou-intranet.log.aliyuncs.com
     accessKeyId: LTAIP6x1l3DXfSxm
     accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
-    project: risk-control
+    project: risk-control-test
     logstore:
       request: request-log-test
       error: error-log-test

+ 1 - 1
risk-control-server/src/main/resources/application-pre.yml

@@ -40,7 +40,7 @@ aliyun:
     endpoint: cn-hangzhou-intranet.log.aliyuncs.com
     accessKeyId: LTAIP6x1l3DXfSxm
     accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
-    project: risk-control
+    project: risk-control-test
     logstore:
       request: request-log
       error: error-log

+ 1 - 1
risk-control-server/src/main/resources/application-prod.yml

@@ -42,7 +42,7 @@ aliyun:
     endpoint: cn-hangzhou-intranet.log.aliyuncs.com
     accessKeyId: LTAIP6x1l3DXfSxm
     accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
-    project: risk-control
+    project: risk-control-test
     logstore:
       request: request-log
       error: error-log

+ 1 - 1
risk-control-server/src/main/resources/application-test.yml

@@ -43,7 +43,7 @@ aliyun:
     endpoint: cn-hangzhou-intranet.log.aliyuncs.com
     accessKeyId: LTAIP6x1l3DXfSxm
     accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
-    project: risk-control
+    project: risk-control-test
     logstore:
       request: request-log-test
       error: error-log-test

+ 38 - 0
risk-control-server/src/main/resources/logback-spring.xml

@@ -11,6 +11,12 @@
     <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
 <!--    <property name="LOG_PATH"  value="${logging.file.path}" />-->
     <springProperty name="LOG_PATH" source="logging.file.path"/>
+    <!-- 缺少以下定义 -->
+    <springProperty name="aliyun_log_endpoint" source="aliyun.log.endpoint"/>
+    <springProperty name="aliyun_log_accessKeyId" source="aliyun.log.accessKeyId"/>
+    <springProperty name="aliyun_log_accessKeySecret" source="aliyun.log.accessKeySecret"/>
+    <springProperty name="aliyun_log_project" source="aliyun.log.project"/>
+    <springProperty name="aliyun_log_logstore_info" source="aliyun.log.logstore.request"/>  <!-- 注入request-log-test -->
 
     <!-- 彩色日志 -->
     <!-- 彩色日志依赖的渲染类 -->
@@ -60,6 +66,36 @@
             <onMismatch>DENY</onMismatch>
         </filter>
     </appender>
+    !-- 阿里云SLS的Appender配置 -->
+    <appender name="LOG_HUB_INFO" class="com.aliyun.openservices.log.logback.LoghubAppender">
+        <!-- 必填参数 -->
+        <endpoint>${aliyun_log_endpoint}</endpoint>
+        <accessKeyId>${aliyun_log_accessKeyId}</accessKeyId>
+        <accessKeySecret>${aliyun_log_accessKeySecret}</accessKeySecret>
+        <project>${aliyun_log_project}</project>
+        <logStore>${aliyun_log_logstore_info}</logStore>
+        <!-- 关键优化参数 -->
+        <totalSizeInBytes>104857600</totalSizeInBytes>  <!-- 内存缓冲区大小(100MB) -->
+        <ioThreadCount>8</ioThreadCount>               <!-- 发送线程数(根据CPU核心数调整) -->
+        <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>  <!-- 批量发送阈值(512KB) -->
+        <batchCountThreshold>4096</batchCountThreshold>  <!-- 批量发送条数 -->
+        <lingerMs>2000</lingerMs>                      <!-- 等待批量发送的时间(毫秒) -->
+        <retries>3</retries>                          <!-- 失败重试次数 -->
+        <maxRetryBackoffMs>3000</maxRetryBackoffMs>   <!-- 最大重试间隔 -->
+
+        <!-- 可选参数 -->
+<!--        <topic>your-topic</topic>  &lt;!&ndash; 如需按Topic分类日志 &ndash;&gt;-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{logTraceId}] %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <!-- 只上传INFO级别日志 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
 
     <!-- 时间滚动输出 level为 INFO 日志 -->
     <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
@@ -188,6 +224,8 @@
         <appender-ref ref="INFO_FILE" />
         <appender-ref ref="WARN_FILE" />
         <appender-ref ref="ERROR_FILE" />
+        <appender-ref ref="LOG_HUB_INFO" />  <!-- 必须添加这一行 -->
+
     </root>
 
 </configuration>