Class SentryAppender

  • All Implemented Interfaces:
    org.apache.logging.log4j.core.Appender, org.apache.logging.log4j.core.filter.Filterable, org.apache.logging.log4j.core.impl.LocationAware, org.apache.logging.log4j.core.LifeCycle, org.apache.logging.log4j.core.LifeCycle2

    @Plugin(name="Sentry",
            category="Core",
            elementType="appender",
            printObject=true)
    public class SentryAppender
    extends org.apache.logging.log4j.core.appender.AbstractAppender
    Appender for Log4j2 in charge of sending the logged events to a Sentry server.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractAppender

        org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B extends org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B>>
      • Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle

        org.apache.logging.log4j.core.LifeCycle.State
    • Field Summary

      • Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

        DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
      • Fields inherited from interface org.apache.logging.log4j.core.Appender

        ELEMENT_TYPE
    • Constructor Summary

      Constructors 
      Constructor Description
      SentryAppender​(@NotNull java.lang.String name, @Nullable org.apache.logging.log4j.core.Filter filter, @Nullable java.lang.String dsn, @Nullable org.apache.logging.log4j.Level minimumBreadcrumbLevel, @Nullable org.apache.logging.log4j.Level minimumEventLevel, @Nullable java.lang.Boolean debug, @Nullable io.sentry.ITransportFactory transportFactory, @NotNull io.sentry.IHub hub, @Nullable java.lang.String[] contextTags)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(@NotNull org.apache.logging.log4j.core.LogEvent eventObject)  
      static @Nullable SentryAppender createAppender​(@Nullable java.lang.String name, @Nullable org.apache.logging.log4j.Level minimumBreadcrumbLevel, @Nullable org.apache.logging.log4j.Level minimumEventLevel, @Nullable java.lang.String dsn, @Nullable java.lang.Boolean debug, @Nullable org.apache.logging.log4j.core.Filter filter, @Nullable java.lang.String contextTags)
      Create a Sentry Appender.
      protected @NotNull io.sentry.Breadcrumb createBreadcrumb​(@NotNull org.apache.logging.log4j.core.LogEvent loggingEvent)
      Creates Breadcrumb from log4j2 LogEvent.
      protected @NotNull io.sentry.SentryEvent createEvent​(@NotNull org.apache.logging.log4j.core.LogEvent loggingEvent)
      Creates SentryEvent from Log4j2 LogEvent.
      void start()  
      • Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender

        error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString
      • Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable

        addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, stop, stop
      • Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle

        equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.apache.logging.log4j.core.LifeCycle

        getState, initialize, isStarted, isStopped, stop
    • Constructor Detail

      • SentryAppender

        public SentryAppender​(@NotNull
                              @NotNull java.lang.String name,
                              @Nullable
                              @Nullable org.apache.logging.log4j.core.Filter filter,
                              @Nullable
                              @Nullable java.lang.String dsn,
                              @Nullable
                              @Nullable org.apache.logging.log4j.Level minimumBreadcrumbLevel,
                              @Nullable
                              @Nullable org.apache.logging.log4j.Level minimumEventLevel,
                              @Nullable
                              @Nullable java.lang.Boolean debug,
                              @Nullable
                              @Nullable io.sentry.ITransportFactory transportFactory,
                              @NotNull
                              @NotNull io.sentry.IHub hub,
                              @Nullable
                              @Nullable java.lang.String[] contextTags)
    • Method Detail

      • createAppender

        @PluginFactory
        @Nullable
        public static @Nullable SentryAppender createAppender​(@Nullable @PluginAttribute("name")
                                                              @Nullable java.lang.String name,
                                                              @Nullable @PluginAttribute("minimumBreadcrumbLevel")
                                                              @Nullable org.apache.logging.log4j.Level minimumBreadcrumbLevel,
                                                              @Nullable @PluginAttribute("minimumEventLevel")
                                                              @Nullable org.apache.logging.log4j.Level minimumEventLevel,
                                                              @Nullable @PluginAttribute("dsn")
                                                              @Nullable java.lang.String dsn,
                                                              @Nullable @PluginAttribute("debug")
                                                              @Nullable java.lang.Boolean debug,
                                                              @Nullable @PluginElement("filter")
                                                              @Nullable org.apache.logging.log4j.core.Filter filter,
                                                              @Nullable @PluginAttribute("contextTags")
                                                              @Nullable java.lang.String contextTags)
        Create a Sentry Appender.
        Parameters:
        name - The name of the Appender.
        minimumBreadcrumbLevel - The min. level of the breadcrumb.
        minimumEventLevel - The min. level of the event.
        dsn - the Sentry DSN.
        debug - if Sentry debug mode should be on
        filter - The filter, if any, to use.
        Returns:
        The SentryAppender.
      • start

        public void start()
        Specified by:
        start in interface org.apache.logging.log4j.core.LifeCycle
        Overrides:
        start in class org.apache.logging.log4j.core.filter.AbstractFilterable
      • append

        public void append​(@NotNull
                           @NotNull org.apache.logging.log4j.core.LogEvent eventObject)
      • createEvent

        @NotNull
        protected @NotNull io.sentry.SentryEvent createEvent​(@NotNull
                                                             @NotNull org.apache.logging.log4j.core.LogEvent loggingEvent)
        Creates SentryEvent from Log4j2 LogEvent.
        Parameters:
        loggingEvent - the log4j2 event
        Returns:
        the sentry event
      • createBreadcrumb

        @NotNull
        protected @NotNull io.sentry.Breadcrumb createBreadcrumb​(@NotNull
                                                                 @NotNull org.apache.logging.log4j.core.LogEvent loggingEvent)
        Creates Breadcrumb from log4j2 LogEvent.
        Parameters:
        loggingEvent - the log4j2 event
        Returns:
        the sentry breadcrumb