Skip to content

Clarify web application shutdown listener configuration - #4408

Open
Shekharrajak wants to merge 2 commits into
apache:2.xfrom
Shekharrajak:docs/2689-web-shutdown-listeners
Open

Shekharrajak wants to merge 2 commits into
apache:2.xfrom
Shekharrajak:docs/2689-web-shutdown-listeners

Conversation

@Shekharrajak

@Shekharrajak Shekharrajak commented Oct 18, 2026 •

Copy link
Copy Markdown

Fixes: #2689

This how it will be rendered in UI:

image

Checklist

  • Base your changes on 2.x branch if you are targeting Log4j 2; use main otherwise
  • ./mvnw verify succeeds (the build instructions)
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests are provided

@rgoers

rgoers commented Oct 18, 2026

Copy link
Copy Markdown
Member

I am not sure if our doc says it anywhere but log4j-web is not required for apps using Spring Boot.

Comment on lines +107 to +112

Context listeners are destroyed in reverse initialization order.
Registering the Log4j listener first allows other listeners to log during their `contextDestroyed()` callbacks before Log4j shuts down.

Since Log4j 2.21.0, this works alongside automatic listener registration;
you do not need to set `isLog4jAutoShutdownDisabled` to `true`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WARNING block just above already says to register Log4jServletContextListener first so it runs last at shutdown.

Suggested change
Context listeners are destroyed in reverse initialization order.
Registering the Log4j listener first allows other listeners to log during their `contextDestroyed()` callbacks before Log4j shuts down.
Since Log4j 2.21.0, this works alongside automatic listener registration;
you do not need to set `isLog4jAutoShutdownDisabled` to `true`.

Comment on lines +161 to +164

If you only need logging during other listeners' `contextDestroyed()` callbacks,
leave this parameter at its default value and follow the
<<log4j-jakarta-web-installation,listener-ordering guidance>>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points back to the same WARNING block. The paragraph above already covers what to do when the parameter is true.

Suggested change
If you only need logging during other listeners' `contextDestroyed()` callbacks,
leave this parameter at its default value and follow the
<<log4j-jakarta-web-installation,listener-ordering guidance>>.

@ramanathan1504

Copy link
Copy Markdown
Contributor

The Log4jServletContainerInitializer fix, the Log4jShutdownOnContextDestroyedListener note and the Spring Boot note are all missing from the page today.
The listener ordering is already covered by the WARNING block in jakarta.adoc. Can we drop the two paragraphs marked inline that repeat it?

@ramanathan1504 ramanathan1504 added this to the 2.27.0 milestone Oct 30, 2026
@ramanathan1504 ramanathan1504 added the port-done No further port needed: all required ports are merged, or none was needed label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port-done No further port needed: all required ports are merged, or none was needed

Projects

Development

Successfully merging this pull request may close these issues.

Document isLog4jAutoShutdownDisabled to enable logging during a web application listener's contextDestroyed

3 participants