Class AbstractCustomAppender

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
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
Direct Known Subclasses:
AliyunSlsAppender, JdbcAppender, LogstashAppender

public abstract class AbstractCustomAppender extends ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
自定义Appender父类.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    默认日志格式化器 直接返回日志消息内容
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent>
     

    Fields inherited from class ch.qos.logback.core.AppenderBase

    name, started

    Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    append(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
     
    abstract String
    当前appender的名称
    abstract void
    executeAppend(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
    执行日志输出
    protected String
    getAppName(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
    获取应用名称
    protected String
    getTenantId(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
    获取租户ID
    protected String
    获取当前用户ID
    protected String
    获取当前用户名称
    protected boolean
     
    void
    setActiveAppender(String activeAppenderStr)
    设置激活的appender名称
    void
    setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)
    设置日志格式化器

    Methods inherited from class ch.qos.logback.core.AppenderBase

    addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, start, stop, toString

    Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ch.qos.logback.core.spi.ContextAware

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
  • Field Details

    • layout

      protected ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout
  • Constructor Details

    • AbstractCustomAppender

      public AbstractCustomAppender()
  • Method Details

    • appenderName

      public abstract String appenderName()
      当前appender的名称

      可用于判断是否激活

      Returns:
      appender名称
    • executeAppend

      public abstract void executeAppend(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
      执行日志输出
      Parameters:
      loggingEvent - 日志事件
    • append

      protected final void append(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
      Specified by:
      append in class ch.qos.logback.core.AppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • setActiveAppender

      public void setActiveAppender(String activeAppenderStr)
      设置激活的appender名称
      Parameters:
      activeAppenderStr - 激活的appender名称,多个以逗号分隔
    • setLayout

      public void setLayout(ch.qos.logback.core.Layout<ch.qos.logback.classic.spi.ILoggingEvent> layout)
      设置日志格式化器
      Parameters:
      layout - 日志格式化器
    • getAppName

      protected String getAppName(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
      获取应用名称
      Parameters:
      loggingEvent - 日志事件
      Returns:
      应用名称
    • getTenantId

      protected String getTenantId(ch.qos.logback.classic.spi.ILoggingEvent loggingEvent)
      获取租户ID
      Returns:
      租户ID
    • getUserId

      protected String getUserId()
      获取当前用户ID
      Returns:
    • getUsername

      protected String getUsername()
      获取当前用户名称
      Returns:
    • isActive

      protected boolean isActive()