diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java index a415f8acbd..41fe810c83 100644 --- a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java @@ -79,6 +79,9 @@ public void autoConfig() throws JoranException { public void autoConfig(ClassLoader classLoader) throws JoranException { String versionStr = EnvUtil.logbackVersion(); + if(versionStr == null) { + versionStr = CoreConstants.NA; + } loggerContext.getStatusManager().add(new InfoStatus(CoreConstants.LOGBACK_CLASSIC_VERSION_MESSAGE + versionStr, loggerContext)); StatusListenerConfigHelper.installIfAsked(loggerContext); List configuratorList = ClassicEnvUtil.loadFromServiceLoader(Configurator.class, classLoader); diff --git a/logback-classic/src/main/java/module-info.java b/logback-classic/src/main/java/module-info.java index 21fc223d3d..80591e490b 100644 --- a/logback-classic/src/main/java/module-info.java +++ b/logback-classic/src/main/java/module-info.java @@ -6,8 +6,9 @@ requires ch.qos.logback.core; uses ch.qos.logback.classic.spi.Configurator; provides org.slf4j.spi.SLF4JServiceProvider with ch.qos.logback.classic.spi.LogbackServiceProvider; - - + + provides ch.qos.logback.classic.spi.Configurator with ch.qos.logback.classic.util.DefaultJoranConfigurator; + exports ch.qos.logback.classic; exports ch.qos.logback.classic.boolex; exports ch.qos.logback.classic.encoder; diff --git a/logback-core/pom.xml b/logback-core/pom.xml index 27bcb4f482..ee13eb9c85 100755 --- a/logback-core/pom.xml +++ b/logback-core/pom.xml @@ -94,11 +94,6 @@ - - true - ${maven.compiler.source} - ${maven.compiler.target} - ${project.build.outputDirectory}/META-INF/MANIFEST.MF diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java index 9777b9640f..511e8069f4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/EnvUtil.java @@ -1,18 +1,21 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2015, QOS.ch. All rights reserved. - * + *

* This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by * the Eclipse Foundation - * - * or (per the licensee's choosing) - * + *

+ * or (per the licensee's choosing) + *

* under the terms of the GNU Lesser General Public License version 2.1 * as published by the Free Software Foundation. */ package ch.qos.logback.core.util; +import java.lang.module.ModuleDescriptor; +import java.util.Optional; + /** * @author Ceki Gülcü */ @@ -30,13 +33,37 @@ private EnvUtil() { * @return current version or null if missing version data */ static public String logbackVersion() { + String moduleVersion = logbackVersionByModule(); + if(moduleVersion != null) + return moduleVersion; + Package pkg = EnvUtil.class.getPackage(); - if(pkg == null) { + if (pkg == null) { return null; } return pkg.getImplementationVersion(); } + /** + *

Returns the current version of logback via class.getModule() or null if data is not + * available. + *

+ * + * @since 1.3.0 + * @return current version or null if missing version data + */ + static private String logbackVersionByModule() { + Module module = EnvUtil.class.getModule(); + if (module == null) + return null; + + ModuleDescriptor md = module.getDescriptor(); + if (md == null) + return null; + Optional opt = md.rawVersion(); + return opt.orElse(null); + } + static public int getJDKVersion(String javaVersionStr) { int version = 0; diff --git a/logback-core/src/main/java/module-info.java b/logback-core/src/main/java/module-info.java index 141449bf63..9d7a1c7bac 100644 --- a/logback-core/src/main/java/module-info.java +++ b/logback-core/src/main/java/module-info.java @@ -15,12 +15,13 @@ exports ch.qos.logback.core.rolling; exports ch.qos.logback.core.rolling.helper; - + exports ch.qos.logback.core.util; + exports ch.qos.logback.core.encoder; exports ch.qos.logback.core.helpers; exports ch.qos.logback.core.html; - + exports ch.qos.logback.core.filter; exports ch.qos.logback.core.model; @@ -51,7 +52,6 @@ exports ch.qos.logback.core.recovery; - exports ch.qos.logback.core.util; exports ch.qos.logback.core.read;