[
https://issues.apache.org/jira/browse/MNG-8086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831926#comment-17831926
]
Michael Osipov edited comment on MNG-8086 at 3/28/24 6:40 PM:
--------------------------------------------------------------
The command you are calling is what I have expected -- wrong. What you are
passing is a Maven *user property*. A valid Java system property has to be
passed to {{java}} and not {{mvn}}. Maven currently promotes user properties to
system properties, but that is not guaranteed to work at all and will be sooner
or later removed. In fact, when you pass that the JVM has already been
intialized and JUL with it. It is too late. What was working for you is
undefined behavior, unfortunately. As you figured out yourself: {{MAVEN_OPTS}}
is what you need. This will work -- always.
was (Author: michael-o):
The command you are calling is what I have expected -- wrong. What you are
passing is a Maven *user property*. A valid Java system property has to be
passed to {{java}} and not {{mvn}}. Maven currently promotes user properties to
system properties, but that is not guaranteed to work at all and will be sooner
or later removed. In fact, when you pass that the JVM has already been
intialized and JUL with it. It is too late. What was working for you is
undefined behavior, unfortunately. As you figured out yourself: MAVEN_OPTS is
what you need. This will work --always.
> Maven no longer initializes logging configuration based on java.util.logging
> config file
> ----------------------------------------------------------------------------------------
>
> Key: MNG-8086
> URL: https://issues.apache.org/jira/browse/MNG-8086
> Project: Maven
> Issue Type: Bug
> Affects Versions: 4.0.0-alpha-12
> Reporter: Iurii Ignatko
> Priority: Major
>
> h3. Bug description and the root cause
> When supplying the logging configuration to the Maven build using
> {{{}-Djava.util.logging.config.file{}}}, it is no longer propagated to the
> logger.
> This started when the [following
> PR|https://github.com/apache/maven/pull/1279] was merged. The reason is [this
> line
> |https://github.com/apache/maven/blob/003a5bc06daa6e74c98e4d8ab45c6643a6844975/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L191]
> in the constructor and as a connected change, [this
> initialization|https://github.com/apache/maven/blob/a5ea944c993d8c087b3d38fdaea55815e668e550/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java#L37]
> in {{org.apache.maven.jline.MessageUtils}}.
> The root cause of the issue lies in the fact that any instance of
> {{org.jline.utils.StyleResolver}}
> [triggers|https://github.com/jline/jline3/blob/19c031c0bccaeea6a4346bc82c04c7bd3ec18888/terminal/src/main/java/org/jline/utils/StyleResolver.java#L27]
> the {{java.util.logging.Logger}} initialization. This process happens before
> MavenCli's
> [doMain|https://github.com/apache/maven/blob/003a5bc06daa6e74c98e4d8ab45c6643a6844975/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L273]
> method is invoked, which
> [populates|https://github.com/apache/maven/blob/003a5bc06daa6e74c98e4d8ab45c6643a6844975/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java#L614]
> the system properties the logging initializer uses.
> Before the migration to JLine, Jansi's JansiMessageBuilderFactory didn't have
> any logger initialization logic (neither by itself nor by any auxiliary
> components created when that library was used). Hence, the system properties
> were all set by the time any logger was found, as that used to happen
> somewhere later in the lifecycle.
> h3. Reproducer
> The issue can be easily reproduced by supplying the following logging
> configuration to any Maven build:
> {code:java}
> handlers=java.util.logging.ConsoleHandler
> .level=FINE
> java.util.logging.ConsoleHandler.level=FINE
> java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter{code}
> When built with Maven version 4.0.0-alpha-10 (or any prior version), note the
> amount of FINE level logs that are being printed.
> Starting from 4.0.0-alpha-12, those log entries are not printed anymore.
> h3. Solution
> The issue can be fixed in multiple ways:
> # Reorganize object creation in Maven such that the logger initialization
> happens after system properties are set.
> # Change in JLine's {{org.jline.utils.StyleResolver}}
> # Some combination of both.
> I was able to do a quick fix using Option (1) as a PoC solution. A proper
> fix, however, is something to decide upon.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)