* Simply said - this must be the first thing application must execute. + *
+ * As an example, when you enable GC logging, it will be always faster than this class.
+ * That is why is this class deprecated and we recommend to use the
+ * {@link GlassFishLoggingConstants#JVM_OPT_LOGGING_MANAGER} and other related options
+ * which guarantee that the log manager will be set.
*
* @author David Matejcek
*/
+@Deprecated
public final class GlassFishLogManagerInitializer {
private GlassFishLogManagerInitializer() {
@@ -43,7 +51,6 @@ private GlassFishLogManagerInitializer() {
}
-
/**
* Tries to set the {@link GlassFishLogManager}as the JVM's {@link LogManager} implementation.
* This must be done before any JUL component is used and remains set until JVM shutdown.
diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java
index 2e17a4cc72a..414377f17d4 100644
--- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java
+++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/cfg/GlassFishLoggingConstants.java
@@ -45,6 +45,13 @@ public class GlassFishLoggingConstants {
* existence.
*/
public static final String JVM_OPT_LOGGING_MANAGER = "java.util.logging.manager";
+
+ /**
+ * System property name to ask the starting log manager to block until application finishes
+ * the configuration.
+ */
+ public static final String JVM_OPT_LOGGING_CFG_BLOCK = "java.util.logging.config.block";
+
/**
* System property name defining property file which will be automatically loaded on startup.
* Usually it is named logging.properties
@@ -52,7 +59,7 @@ public class GlassFishLoggingConstants {
public static final String JVM_OPT_LOGGING_CFG_FILE = "java.util.logging.config.file";
/**
* System property telling the GlassFishLogManager to use defaults if there would not be any
- * logging.properties neither set by {@value #JVM_OPT_LOGGING_CFG_FILE} nor available on classpath.
+ * logging.properties set by {@value #JVM_OPT_LOGGING_CFG_FILE}.
*
* Defaults use the SimpleLogHandler and level INFO or level set by * {@value #JVM_OPT_LOGGING_CFG_DEFAULT_LEVEL} @@ -76,6 +83,9 @@ public class GlassFishLoggingConstants { *
* If the property is not set, GJULE makes the decision based on the (*.printSource
* property) - if any formatter requires this feature, the feature is enabled.
+ * This applies just when the formatter is set from the supplied log manager configuration,
+ * not when you configure formatter from your code.
+ *
*
* It is disabled otherwise. */ diff --git a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/OneLineFormatter.java b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/OneLineFormatter.java index 0dd0e1dd801..2500d80967d 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/OneLineFormatter.java +++ b/nucleus/glassfish-jul-extension/src/main/java/org/glassfish/main/jul/formatter/OneLineFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -19,7 +19,9 @@ import java.util.Arrays; import java.util.logging.Formatter; import java.util.logging.LogRecord; +import java.util.logging.Logger; +import org.glassfish.main.jul.cfg.GlassFishLoggingConstants; import org.glassfish.main.jul.cfg.LogProperty; import org.glassfish.main.jul.record.GlassFishLogRecord; @@ -31,6 +33,12 @@ /** * Fast {@link Formatter} usable in tests or even in production if you need only simple logs with * time, level and messages. + *
+ * Note that if you configured the formatter from your code (and not a property file), + * if you want to source class and method automatically detected, you have to enable + * {@link GlassFishLoggingConstants#KEY_CLASS_AND_METHOD_DETECTION_ENABLED}. Without that the output + * will contain just class and method fields manually set to the LogRecord or using {@link Logger} + * methods which have these parameters to do that. * * @author David Matejcek */ diff --git a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLogManagerLifeCycleTest.java b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLogManagerLifeCycleTest.java index e54895824df..285682e4c7f 100644 --- a/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLogManagerLifeCycleTest.java +++ b/nucleus/glassfish-jul-extension/src/test/java/org/glassfish/main/jul/GlassFishLogManagerLifeCycleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -98,7 +98,6 @@ public static void resetConfiguration() throws Exception { * {@link BlockingExternallyManagedLogHandler} to block logging system in * {@link GlassFishLoggingStatus#CONFIGURING} state, so it is just collecting * log records to the StartupQueue. - *
*/
@Test
@Order(1)
diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml
index 0423a28a29f..faf623f6f25 100644
--- a/nucleus/parent/pom.xml
+++ b/nucleus/parent/pom.xml
@@ -186,6 +186,7 @@