|
@@ -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> <!– 如需按Topic分类日志 –>-->
|
|
|
+ <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>
|