Package io.github.pimak.ntfy.jul
Class NtfyJulInstaller
java.lang.Object
io.github.pimak.ntfy.jul.NtfyJulInstaller
Programmatic one-liner install of the ntfy JUL handler from the ambient environment:
NtfyJulInstaller.install() early in main attaches a NtfyJulHandler to the root
logger when the environment configures ntfy (NTFY_URL/NTFY_TOPIC,
-Dntfy.*, or a trusted classpath ntfy.properties — see JulAmbientConfig for the
classpath-endpoint opt-in guard), and does nothing otherwise.
To scope alerting to a subtree instead of the whole application, pass that subtree's logger to
install(Logger) — the same "attach to the specific logger, not root" scoping the other
adapters document. For fully declarative installation (no code at all, e.g. Tomcat's
logging.properties) use NtfyJulAutoHandler instead.
The returned handler owns its engine: call uninstall(Logger, NtfyJulHandler) (or
removeHandler + NtfyJulHandler.close()) on shutdown to flush the async queue and
release the HTTP client. JUL's LogManager shutdown hook also closes attached handlers on
normal JVM exit.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<NtfyJulHandler> install()Installs on the root logger.static Optional<NtfyJulHandler> Resolves the ambient config and, when active and vetted, attaches a startedNtfyJulHandlertologger.static voiduninstall(Logger logger, NtfyJulHandler handler) Detacheshandlerfromloggerand stops its engine.
-
Method Details
-
install
Installs on the root logger. Seeinstall(Logger). -
install
Resolves the ambient config and, when active and vetted, attaches a startedNtfyJulHandlertologger. Empty — with nothing attached — when ntfy is not configured, the classpath-endpoint guard refused, or resolution/construction failed (reported onSystem.err); like the auto-handler, this entry point never lets an alerting-setup failure propagate into the caller. -
uninstall
Detacheshandlerfromloggerand stops its engine.
-