Class ErrorReportAppender

  • 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 ErrorReportAppender
    extends ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    Logging Event를 감지하여 설정한 레벨이상의 로그를 알림.
    Version:
    1.0
    Author:
    always0ne
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ErrorLogsRepository errorLogsRepository  
      private LogConfig logConfig  
      • Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

        name, started
      • Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

        context
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void append​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
      이벤트를 감지했을 때 설정한 레벨의 이상인지 확인한 후,
      DB에 저장, Slack채널에 알림 옵션에 맞게 동작한다.
      private net.gpedro.integrations.slack.SlackField generateSlackField​(java.lang.String title, java.lang.String value, java.lang.Boolean shorten)
      Slack Field 생성자 역할을 하는 메소드.
      private void sendSlackMessage​(ErrorLogs errorLog)
      Slack 메시지 제작 후 설정된 채널로 알림메시지를 전송한다.
      - 전달되는 Data
      Error Message, Stack Trace, URL, Parameter, Header, Body, UserInfo, User Agent, Time, Server Name, Server OS, Server Host Name
      • Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

        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
    • Constructor Detail

      • ErrorReportAppender

        public ErrorReportAppender()
    • Method Detail

      • append

        protected void append​(ch.qos.logback.classic.spi.ILoggingEvent eventObject)
        이벤트를 감지했을 때 설정한 레벨의 이상인지 확인한 후,
        DB에 저장, Slack채널에 알림 옵션에 맞게 동작한다.
        Specified by:
        append in class ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
        Parameters:
        eventObject - 로깅 이벤트
      • sendSlackMessage

        private void sendSlackMessage​(ErrorLogs errorLog)
        Slack 메시지 제작 후 설정된 채널로 알림메시지를 전송한다.
        - 전달되는 Data
        Error Message, Stack Trace, URL, Parameter, Header, Body, UserInfo, User Agent, Time, Server Name, Server OS, Server Host Name
        Parameters:
        errorLog - 에러 정보
      • generateSlackField

        private net.gpedro.integrations.slack.SlackField generateSlackField​(java.lang.String title,
                                                                            java.lang.String value,
                                                                            java.lang.Boolean shorten)
        Slack Field 생성자 역할을 하는 메소드.
        Parameters:
        title - 필드 제목
        value - 필드 값
        shorten - 필드의 가로폭이 절반으로 좁혀지는지 여부
        Returns:
        SlackField