Fix JUL logging (#792)

This commit is contained in:
Guillaume Nodet
2023-03-10 17:19:42 +01:00
committed by GitHub
parent d771375870
commit f6de618454
12 changed files with 37 additions and 3 deletions

View File

@@ -49,6 +49,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>

View File

@@ -59,6 +59,7 @@ import org.mvndaemon.mvnd.common.logging.ClientOutput;
import org.mvndaemon.mvnd.common.logging.TerminalOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import static org.mvndaemon.mvnd.client.DaemonParameters.LOG_EXTENSION;
@@ -146,6 +147,9 @@ public class DefaultClient implements Client {
}
}
// Install JUL -> SLF4j bridge
SLF4JBridgeHandler.install();
int exitCode = 0;
boolean noBuffering = batchMode || parameters.noBuffering();
try (TerminalOutput output = new TerminalOutput(noBuffering, parameters.rollingWindowSize(), logFile)) {

View File

@@ -431,7 +431,7 @@ public class DaemonConnector {
Environment.MVND_HOME.addSystemProperty(args, mvndHome.toString());
args.add("-Dmaven.home=" + mvndHome.resolve("mvn"));
args.add("-Dmaven.conf=" + mvndHome.resolve("mvn").resolve("conf"));
args.add("-Dclassworlds.conf=" + mvndHome.resolve("bin").resolve("mvnd-server.conf"));
args.add("-Dclassworlds.conf=" + mvndHome.resolve("bin").resolve("mvnd-daemon.conf"));
Environment.MVND_JAVA_HOME.addSystemProperty(
args, parameters.javaHome().toString());

View File

@@ -243,7 +243,7 @@ public class DaemonParameters {
public Path logbackConfigurationPath() {
return property(Environment.MVND_LOGBACK)
.orDefault(() -> mvndHome()
.resolve("mvn/conf/logging/logback-server.xml")
.resolve("mvn/conf/logging/logback-daemon.xml")
.toString())
.orFail()
.asPath();

View File

@@ -31,6 +31,9 @@
<artifact id="ch.qos.logback:logback-core">
<exclusion id="*:*"/>
</artifact>
<artifact id="org.slf4j:jul-to-slf4j">
<exclusion id="*:*"/>
</artifact>
</artifactSet>
<artifactSet to="/mvn/lib/ext">

View File

@@ -31,6 +31,9 @@
<artifact id="ch.qos.logback:logback-core">
<exclusion id="*:*"/>
</artifact>
<artifact id="org.slf4j:jul-to-slf4j">
<exclusion id="*:*"/>
</artifact>
</artifactSet>
<artifactSet to="/mvn/lib/ext">

View File

@@ -19,6 +19,7 @@ main is org.mvndaemon.mvnd.client.DefaultClient from plexus.core
set maven.home default ${mvnd.home}/mvn
set maven.conf default ${maven.home}/conf
set java.util.logging.config.file default ${maven.conf}/logging/java.util.logging.properties
set logback.configurationFile default ${maven.conf}/logging/logback-client.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml

View File

@@ -19,7 +19,8 @@ main is org.mvndaemon.mvnd.daemon.Server from plexus.core
set maven.home default ${mvnd.home}/mvn
set maven.conf default ${maven.home}/conf
set logback.configurationFile default ${maven.conf}/logging/logback-server.xml
set java.util.logging.config.file default ${maven.conf}/logging/java.util.logging.properties
set logback.configurationFile default ${maven.conf}/logging/logback-daemon.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml
[plexus.core]

View File

@@ -18,6 +18,7 @@ main is org.apache.maven.cli.MavenCli from plexus.core
set maven.conf default ${maven.home}/conf
set java.util.logging.config.file default ${maven.conf}/logging/java.util.logging.properties
set logback.configurationFile default ${maven.conf}/logging/logback-mvn.xml
set logback.configurationFile.fallback default ${maven.conf}/logging/logback.xml

View File

@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

View File

@@ -20,6 +20,7 @@
| mvnd client log configuration
-->
<configuration>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>