Class NtfyLogbackConfigurator

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
io.github.pimak.ntfy.logback.NtfyLogbackConfigurator
All Implemented Interfaces:
ch.qos.logback.classic.spi.Configurator, ch.qos.logback.core.spi.ContextAware

public class NtfyLogbackConfigurator extends ch.qos.logback.core.spi.ContextAwareBase implements ch.qos.logback.classic.spi.Configurator
A Logback Configurator SPI implementation that auto-installs the ntfy appender on the root logger with zero XML — activated only when the ambient environment actually configures ntfy. Registered via META-INF/services/ch.qos.logback.classic.spi.Configurator; Logback calls ContextAwareBase.setContext(ch.qos.logback.core.Context) then configure(LoggerContext) during default configuration (when no logback.xml/logback-test.xml is present, or as one link in the configurator chain).

Config is loaded via ConfigLoader.load() (system properties > env > classpath ntfy.properties > defaults). If the resolved config is not active, this configurator does nothing beyond an info status and hands off to the next configurator. If the endpoint URL was supplied only by a classpath ntfy.properties and the operator has not opted in via ntfy.allow-classpath-endpoint / NTFY_ALLOW_CLASSPATH_ENDPOINT, installation is refused with a warn status (any jar on the classpath can carry such a file). Otherwise it builds a LogbackAlertAppender (injecting the config directly), attaches it to the root logger, and registers a reset-resistant NtfyLogbackReattachListener so a later application JoranConfigurator run cannot silently detach it.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface ch.qos.logback.classic.spi.Configurator

    ch.qos.logback.classic.spi.Configurator.ExecutionStatus
  • Field Summary

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

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ch.qos.logback.classic.spi.Configurator.ExecutionStatus
    configure(ch.qos.logback.classic.LoggerContext loggerContext)
     

    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, toString, wait, wait, wait

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

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

    • NtfyLogbackConfigurator

      public NtfyLogbackConfigurator()
  • Method Details

    • configure

      public ch.qos.logback.classic.spi.Configurator.ExecutionStatus configure(ch.qos.logback.classic.LoggerContext loggerContext)
      Specified by:
      configure in interface ch.qos.logback.classic.spi.Configurator