Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JUL logging #792

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
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;

Expand Down Expand Up @@ -146,6 +147,9 @@ public static void main(String[] argv) throws Exception {
}
}

// Install JUL -> SLF4j bridge
SLF4JBridgeHandler.install();

int exitCode = 0;
boolean noBuffering = batchMode || parameters.noBuffering();
try (TerminalOutput output = new TerminalOutput(noBuffering, parameters.rollingWindowSize(), logFile)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private Process startDaemonProcess(String daemonId, ClientOutput output) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public Path multiModuleProjectDirectory(Path projectDir) {
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();
Expand Down
3 changes: 3 additions & 0 deletions dist-m39/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
3 changes: 3 additions & 0 deletions dist-m40/src/main/provisio/maven-distro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
1 change: 1 addition & 0 deletions dist/src/main/distro/bin/mvnd-client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions dist/src/main/distro/mvn/bin/mvn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions dist/src/main/distro/mvn/conf/logging/java.util.logging.properties
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions dist/src/main/distro/mvn/conf/logging/logback-client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down