[java-identity-provider] branch maint-4 updated: IDP-1948 - LoggingService impl logs IdP startup info, including reload
Scott Cantor
cantor.2 at osu.edu
Tue Aug 23 16:31:31 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-4
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=e3493d4ed47c20ed0337e26c9b0a37028974b807
The following commit(s) were added to refs/heads/maint-4 by this push:
new e3493d4ed IDP-1948 - LoggingService impl logs IdP startup info, including reload
e3493d4ed is described below
commit e3493d4ed47c20ed0337e26c9b0a37028974b807
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Aug 23 12:31:27 2022 -0400
IDP-1948 - LoggingService impl logs IdP startup info, including reload
https://shibboleth.atlassian.net/browse/IDP-1948
---
.../shibboleth/idp/log/LogbackLoggingService.java | 77 +--------------
.../idp/admin/impl/LogImplementationDetails.java | 110 +++++++++++++++++++++
.../net/shibboleth/idp/conf/global-system.xml | 4 +-
3 files changed, 115 insertions(+), 76 deletions(-)
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java b/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
index dbda37fae..fc1feeb31 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
@@ -19,23 +19,17 @@ package net.shibboleth.idp.log;
import java.io.IOException;
import java.io.InputStream;
-import java.nio.file.Path;
import java.time.Instant;
-import java.util.List;
-import java.util.ServiceLoader;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
-import com.google.common.base.StandardSystemProperty;
import com.google.common.io.Closeables;
import ch.qos.logback.classic.LoggerContext;
@@ -44,10 +38,6 @@ import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.status.ErrorStatus;
import ch.qos.logback.core.status.InfoStatus;
import ch.qos.logback.core.status.StatusManager;
-import net.shibboleth.idp.Version;
-import net.shibboleth.idp.module.IdPModule;
-import net.shibboleth.idp.module.ModuleContext;
-import net.shibboleth.idp.plugin.IdPPlugin;
import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
@@ -61,6 +51,7 @@ import net.shibboleth.utilities.java.support.service.ServiceableComponent;
* Simple {@link LoggingService} that watches for logback configuration file changes
* and reloads the file when a change occurs.
*/
+ at SuppressWarnings("removal")
public class LogbackLoggingService extends AbstractReloadableService<Object>
implements LoggingService, ApplicationContextAware {
@@ -210,7 +201,6 @@ public class LogbackLoggingService extends AbstractReloadableService<Object>
configurator.setContext(loggerContext);
configurator.doConfigure(loggingConfig);
loggerContext.start();
- logImplementationDetails();
} catch (final JoranException e) {
throw new ServiceException(e);
}
@@ -235,67 +225,4 @@ public class LogbackLoggingService extends AbstractReloadableService<Object>
}
}
- /**
- * Log the IdP version and Java version and vendor at INFO level.
- *
- * Log system properties defined by {@link StandardSystemProperty} at DEBUG level.
- */
- protected void logImplementationDetails() {
- final Logger logger = LoggerFactory.getLogger(LogbackLoggingService.class);
- logger.info("Shibboleth IdP Version {}", Version.getVersion());
- logger.info("Java version='{}' vendor='{}'", StandardSystemProperty.JAVA_VERSION.value(),
- StandardSystemProperty.JAVA_VENDOR.value());
- if (logger.isDebugEnabled()) {
- for (final StandardSystemProperty standardSystemProperty : StandardSystemProperty.values()) {
- logger.debug("{}", standardSystemProperty);
- }
- }
- final List<IdPPlugin> plugins = ServiceLoader.
- load(IdPPlugin.class).
- stream().
- map(e->e.get()).
- collect(Collectors.toList());
- if (plugins.isEmpty()) {
- logger.info("No Plugins Loaded");
- } else {
- logger.info("Plugins:");
- for (final IdPPlugin idpPlugin : plugins) {
- logger.info("\t\t{} : v{}.{}.{}", idpPlugin.getPluginId(), idpPlugin.getMajorVersion(),
- idpPlugin.getMajorVersion(), idpPlugin.getPatchVersion());
- }
- }
- Path idpHome;
- final String homeAsString =
- loggerContext.getProperty(IdPPropertiesApplicationContextInitializer.IDP_HOME_PROPERTY);
- try {
- if (homeAsString != null) {
- idpHome = Path.of(homeAsString);
- } else {
- idpHome = null;
- }
- } catch (final RuntimeException e) {
- logger.info("Could not resolve idpHome {} ", homeAsString, e);
- idpHome = null;
- }
-
- if (idpHome != null) {
- final ModuleContext context = new ModuleContext(idpHome);
- final List<IdPModule> modules = ServiceLoader.
- load(IdPModule.class).
- stream().
- map(e->e.get()).
- filter(f->f.isEnabled(context)).
- collect(Collectors.toList());
- if (modules.isEmpty()) {
- logger.info("No Modules Enabled");
- } else {
- logger.info("Enabled Modules:");
- for (final IdPModule module : modules) {
- logger.info("\t\t{}", module.getName(context));
- }
- }
- } else {
- logger.info("Could not enumerate Modules");
- }
- }
-}
+}
\ No newline at end of file
diff --git a/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/LogImplementationDetails.java b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/LogImplementationDetails.java
new file mode 100644
index 000000000..1b94fd067
--- /dev/null
+++ b/idp-admin-impl/src/main/java/net/shibboleth/idp/admin/impl/LogImplementationDetails.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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.
+ */
+
+package net.shibboleth.idp.admin.impl;
+
+import java.nio.file.Path;
+import java.util.List;
+import java.util.ServiceLoader;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.StandardSystemProperty;
+
+import net.shibboleth.idp.Version;
+import net.shibboleth.idp.module.IdPModule;
+import net.shibboleth.idp.module.ModuleContext;
+import net.shibboleth.idp.plugin.IdPPlugin;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+/**
+ * A bean that logs IdP internals when instantiated.
+ *
+ * @since 4.3.0
+ */
+public final class LogImplementationDetails {
+
+ /**
+ * Log the IdP version and Java version and vendor at INFO level.
+ *
+ * Log system properties defined by {@link StandardSystemProperty} at DEBUG level.
+ *
+ * @param idpHomeLocation idp.home property
+ */
+ public LogImplementationDetails(@Nullable @NotEmpty final String idpHomeLocation) {
+
+ final Logger logger = LoggerFactory.getLogger(LogImplementationDetails.class);
+ logger.info("Shibboleth IdP Version {}", Version.getVersion());
+ logger.info("Java version='{}' vendor='{}'", StandardSystemProperty.JAVA_VERSION.value(),
+ StandardSystemProperty.JAVA_VENDOR.value());
+ if (logger.isDebugEnabled()) {
+ for (final StandardSystemProperty standardSystemProperty : StandardSystemProperty.values()) {
+ logger.debug("{}", standardSystemProperty);
+ }
+ }
+ final List<IdPPlugin> plugins = ServiceLoader.
+ load(IdPPlugin.class).
+ stream().
+ map(e->e.get()).
+ collect(Collectors.toList());
+ if (plugins.isEmpty()) {
+ logger.info("No Plugins Loaded");
+ } else {
+ logger.info("Plugins:");
+ for (final IdPPlugin idpPlugin : plugins) {
+ logger.info("\t\t{} : v{}.{}.{}", idpPlugin.getPluginId(), idpPlugin.getMajorVersion(),
+ idpPlugin.getMajorVersion(), idpPlugin.getPatchVersion());
+ }
+ }
+ Path idpHome;
+ try {
+ if (idpHomeLocation != null) {
+ idpHome = Path.of(idpHomeLocation);
+ } else {
+ idpHome = null;
+ }
+ } catch (final RuntimeException e) {
+ logger.info("Could not resolve idp.home from {} ", idpHomeLocation, e);
+ idpHome = null;
+ }
+
+ if (idpHome != null) {
+ final ModuleContext context = new ModuleContext(idpHome);
+ final List<IdPModule> modules = ServiceLoader.
+ load(IdPModule.class).
+ stream().
+ map(e->e.get()).
+ filter(f->f.isEnabled(context)).
+ collect(Collectors.toList());
+ if (modules.isEmpty()) {
+ logger.info("No Modules Enabled");
+ } else {
+ logger.info("Enabled Modules:");
+ for (final IdPModule module : modules) {
+ logger.info("\t\t{}", module.getName(context));
+ }
+ }
+ } else {
+ logger.warn("Could not enumerate Modules");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
index 92148b692..82c7311b8 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
@@ -87,7 +87,9 @@
depends-on="systemPrereqs,shibboleth.LoggingService"
p:parserPool-ref="shibboleth.ParserPool"
p:metricRegistry-ref="shibboleth.metrics.MetricRegistry" />
-
+
+ <bean class="net.shibboleth.idp.admin.impl.LogImplementationDetails" c:_0="%{idp.home}" />
+
<bean class="net.shibboleth.idp.spring.DeprecatedPropertyBean">
<property name="deprecatedProperties">
<map>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list