Class AliyunSlsAppender

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
com.elitesland.ystdms.sys.log.appender.AbstractCustomAppender
com.elitesland.ystdms.sys.log.appender.AliyunSlsAppender
All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle

public class AliyunSlsAppender extends AbstractCustomAppender
  • Constructor Details

    • AliyunSlsAppender

      public AliyunSlsAppender()
  • Method Details

    • appenderName

      public String appenderName()
      Description copied from class: AbstractCustomAppender
      当前appender的名称

      可用于判断是否激活

      Specified by:
      appenderName in class AbstractCustomAppender
      Returns:
      appender名称
    • start

      public void start()
      启动Appender 初始化配置、创建生产者、启动发送线程
      Specified by:
      start in interface ch.qos.logback.core.spi.LifeCycle
      Overrides:
      start in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • executeAppend

      public void executeAppend(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
      追加日志事件 将日志事件转换为LogItem并放入队列等待异步发送
      Specified by:
      executeAppend in class AbstractCustomAppender
      Parameters:
      loggingEvent - 日志事件
    • stop

      public void stop()
      停止Appender 停止发送线程、关闭生产者、清理资源
      Specified by:
      stop in interface ch.qos.logback.core.spi.LifeCycle
      Overrides:
      stop in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • getEndpoint

      public String getEndpoint()
      获取SLS服务入口
      Returns:
      SLS服务入口地址
    • setEndpoint

      public void setEndpoint(String endpoint)
      设置SLS服务入口
      Parameters:
      endpoint - SLS服务入口地址
    • setAccessKeyId

      public void setAccessKeyId(String accessKeyId)
      设置AccessKey ID
      Parameters:
      accessKeyId - AccessKey ID
    • setAccessKeySecret

      public void setAccessKeySecret(String accessKeySecret)
      设置AccessKey Secret
      Parameters:
      accessKeySecret - AccessKey Secret
    • setProject

      public void setProject(String project)
      设置SLS项目名称
      Parameters:
      project - SLS项目名称
    • setLogStore

      public void setLogStore(String logStore)
      设置SLS日志库名称
      Parameters:
      logStore - SLS日志库名称
    • setTopic

      public void setTopic(String topic)
      设置日志主题
      Parameters:
      topic - 日志主题
    • setSource

      public void setSource(String source)
      设置日志来源
      Parameters:
      source - 日志来源
    • setTotalSizeInBytes

      public void setTotalSizeInBytes(Integer totalSizeInBytes)
      设置单个Producer实例能缓存的日志大小上限
      Parameters:
      totalSizeInBytes - 缓存大小上限(字节),为null时使用默认值
    • setMaxBlockMs

      public void setMaxBlockMs(Integer maxBlockMs)
      设置调用者在send方法上的最大阻塞时间
      Parameters:
      maxBlockMs - 最大阻塞时间(毫秒),为null时使用默认值
    • setIoThreadCount

      public void setIoThreadCount(Integer ioThreadCount)
      设置执行日志发送任务的线程池大小
      Parameters:
      ioThreadCount - 线程池大小,为null时使用默认值
    • setBatchSizeThresholdInBytes

      public void setBatchSizeThresholdInBytes(Integer batchSizeThresholdInBytes)
      设置批次大小阈值
      Parameters:
      batchSizeThresholdInBytes - 批次大小阈值(字节),为null时使用默认值
    • setBatchCountThreshold

      public void setBatchCountThreshold(Integer batchCountThreshold)
      设置批次数量阈值
      Parameters:
      batchCountThreshold - 批次数量阈值,为null时使用默认值
    • setLingerMs

      public void setLingerMs(Integer lingerMs)
      设置ProducerBatch的逗留时间
      Parameters:
      lingerMs - 逗留时间(毫秒),为null时使用默认值
    • setRetries

      public void setRetries(Integer retries)
      设置重试次数
      Parameters:
      retries - 重试次数,为null时使用默认值
    • setMaxReservedAttempts

      public void setMaxReservedAttempts(Integer maxReservedAttempts)
      设置最大保留尝试次数
      Parameters:
      maxReservedAttempts - 最大保留尝试次数,为null时使用默认值
    • setBaseRetryBackoffMs

      public void setBaseRetryBackoffMs(Integer baseRetryBackoffMs)
      设置首次重试的退避时间
      Parameters:
      baseRetryBackoffMs - 退避时间(毫秒),为null时使用默认值
    • setMaxRetryBackoffMs

      public void setMaxRetryBackoffMs(Integer maxRetryBackoffMs)
      设置重试的最大退避时间
      Parameters:
      maxRetryBackoffMs - 最大退避时间(毫秒),为null时使用默认值
    • setAdjustShardHash

      public void setAdjustShardHash(Boolean adjustShardHash)
      设置是否需要调整shardHash
      Parameters:
      adjustShardHash - 是否调整shardHash,为null时使用默认值
    • setBuckets

      public void setBuckets(Integer buckets)
      设置shardHash重新分组的数量
      Parameters:
      buckets - 分组数量,为null时使用默认值