Skip to content

Improve log messages - #854

Closed
michael-o wants to merge 1 commit into
masterfrom
kriegaex-improvements
Closed

michael-o wants to merge 1 commit into
masterfrom
kriegaex-improvements

Conversation

@michael-o

Copy link
Copy Markdown
Member

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@kriegaex kriegaex left a comment

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.

Of course, my review is non-binding, but you might want to consider the suggestions anyway. 🙂

repeatScan |= scanServiceProviderConfigFile(cp, configFileReader);
} catch (final IOException e) {
log.warn(e.getMessage());
log.warn("Failed to scan service provider config file " + serviceProviderConfigFile, e);

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.

I would prefer

log.warn( "Failed to scan service provider config file " + serviceProviderConfigFile );
log.debug( e );

Less noise in the warn log, full exception stack trace in the debug log.

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.

think it is saner to keep it together (or totally duplicate the line) cause loggers are not output streams, warn and debug can be routed to different output and there is no order delivery guarantee between them if executed super fast

@kriegaex kriegaex Sep 22, 2026 •

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.

@rmannibucau I thought that the log channels also correspond to log levels, i.e. that e.g. debug is a superset of warn with more detail. Is that assumption false? Is it really necessary to force users to see stack traces in the warn log?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

both messages are disjoint and that is not OK to print it like that, moreove it would need to consistent with the rest of the log statements which it is not.

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.

@kriegaex it is not a superset just a plain hierarchy but you cant assume 2 disjoint messages will be linked if there is no explicit link between there like there

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What can be done is:

if (debug enabled)
log.warn(message, e)
else
log.warn(message)

This pattern we us in several places.

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.

if (debug enabled)
log.warn(message, e)
else
log.warn(message + "'" + e.getMessage() + "'")

maybe (or anything formatting you like) to not loose the error message which is often the key to understand the error - less critical when you have the real stack/causes

Comment thread src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java Outdated
}
} catch (final IOException e) {
log.warn("Not a JAR file candidate. Ignoring classpath element '" + fileName + "' (" + e + ").");
log.warn("Not a JAR file candidate. Ignoring classpath element '" + fileName + "'", e);

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.

Here, I also would rather split the warning and logging the exception stack trace, see above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, see above.

@kriegaex kriegaex left a comment

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.

If the regular committers in the project disagree with my suggestions, there is nothing I can do. I can live with the result of this PR. Thank you so much for taking the time to open and process it upon my request. I do appreciate that. 🙂

@michael-o

Copy link
Copy Markdown
Member Author

Merged with 7388b57.

@michael-o michael-o closed this Sep 26, 2026
@michael-o
michael-o deleted the kriegaex-improvements branch September 26, 2026 16:37
@github-actions github-actions Bot removed this from the 3.6.3 milestone Sep 26, 2026
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