Skip to content

Fix stray log lines in version.sh/version.bat output - #1057

Open
csutherl wants to merge 1 commit into
apache:mainfrom
csutherl:fix-version-loglines
Open

Fix stray log lines in version.sh/version.bat output#1057
csutherl wants to merge 1 commit into
apache:mainfrom
csutherl:fix-version-loglines

Conversation

@csutherl

@csutherl csutherl commented Sep 2, 2026

Copy link
Copy Markdown
Member

Probing the optional native/OpenSSL libraries in ServerInfo.main() triggers their initialization, which logged java.util.logging messages into the version output. The last attempt to address this lowered two parent loggers to WARNING, but WARNING did not suppress the SEVERE "incompatible Tomcat Native version" message, and no strong reference was kept to the loggers so the configured level could be garbage collected before the init code logged.

This change adds a capturing handler to the loggers involved with useParentHandlers=false so nothing reaches the console, retaining strong references to avoid the weak-reference GC issue. Then the captured incompatible-version message from tomcat-native is re-emitted under "APR loaded: false" so that outcome is no longer unexplained and gives a clear action step before they may run into the problem at runtime.

As an alternate approach that's much simpler we could simply ignore the WARN and output APR loaded: false without any additional information for the user. Thoughts?

Probing the optional native/OpenSSL libraries in ServerInfo.main()
triggers their initialization, which logged java.util.logging messages
into the version output.

The previous fix lowered two parent loggers to WARNING, but WARNING did
not suppress the SEVERE "incompatible Tomcat Native version" message,
and no strong reference was kept to the loggers so the configured level
could be garbage collected before the init code logged.

Instead, attach a capturing handler to the loggers involved with
useParentHandlers=false so nothing reaches the console, retaining strong
references to avoid the weak-reference GC issue. The captured
incompatible-version message is re-emitted under "APR loaded: false" so
that outcome is no longer unexplained.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* the capturing handler and {@code useParentHandlers=false} configured on
* it) before the library initialization code logs.
*/
private static final List<Logger> capturedLoggers = new ArrayList<>();

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.

Is it possible to disable this thing ?

@markt-asf

Copy link
Copy Markdown
Contributor

This does seem to be of those things that sounds simple but quickly ends up needing a fair amount of code. If not overly concerned, providing there are users that find this information useful. Generally, I would lean towards providing information on why something failed if we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants