-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIFI-9688 Improve Logback shutdown handling #5805
Conversation
- Added environment variable to disable Logback shutdown on web application termination - Added shutdown hook to Logback configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good. I wanted to document that the use of nifi.sh run
and Ctrl+C may not take advantage of this improvement. nifi.sh start
and nifi.sh stop
do show the shutdown logging. Also tested an invocation of one of the system tests (with a modified bootstrap.conf).
@@ -50,6 +50,9 @@ export NIFI_PID_DIR | |||
NIFI_LOG_DIR="$(setOrDefault "$NIFI_LOG_DIR" "$NIFI_HOME/logs")" | |||
export NIFI_LOG_DIR | |||
|
|||
# Disable automatic Logback Initializer to avoid shutdown on web application termination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to document alternatives to the use of the environment variable to activate this behavior. I noticed this issue in the context of working on the system tests. There is a bootstrap.conf
available to set system properties, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for feedback @greyp9! The Logback documentation describes the configuration options under the WebShutdownHook section. Will update this pull request to include changes to bootstrap.conf in the system tests.
Thanks @exceptionfactory ! Definitely a great catch. I was really confused just the other day because i wasn't seeing some logs that I expected on shutdown. And then I found this Jira. Thanks for fixing! |
* NIFI-9688 Improved Logback shutdown handling - Added environment variable to disable Logback shutdown on web application termination - Added shutdown hook to Logback configuration - Added Logback shutdown hook configuration to system tests
* NIFI-9688 Improved Logback shutdown handling - Added environment variable to disable Logback shutdown on web application termination - Added shutdown hook to Logback configuration - Added Logback shutdown hook configuration to system tests
Description of PR
NIFI-9688 Improves Logback shutdown handling, avoiding premature closure of the Logback context during application shutdown, and enabling log messages to be written during application termination.
The default LogbackServletContainerInitializer registers a
LogbackServletContainerListener
that closes the Logback context on web application shutdown. When Jetty registers NiFi web applications, it configures the Logback initializer using the standard Java ServiceLoader. With this behavior, Jetty callscontextDestroyed
on the Logback Listener before NiFi termination has completed. This results is missing a number of log messages when shutting down NiFi.Setting the
logbackDisableServletContainerInitializer
environment variable totrue
disables the default Logback listener registration, avoiding the premature context shutdown. Adding theDelayingShutdownHook
to thelogback.xml
configuration allows Logback to perform a clean shutdown after NiFi termination has finished.In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
main
)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squash
or use--force
when pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean install
at the rootnifi
folder?LICENSE
file, including the mainLICENSE
file undernifi-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-assembly
?.displayName
in addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.