feat(core): Add DefaultConfiguratorFactory for JBoss Log Manager 3.x.

Change-Id: I6bf88c9e6c8c4aba303cc1d18e8f18c917dd6b88
diff --git a/core/pom.xml b/core/pom.xml
index d01555b..18da1a8 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -24,14 +24,23 @@
     <dependency>
       <groupId>org.jboss.logmanager</groupId>
       <artifactId>jboss-logmanager-embedded</artifactId>
+      <version>1.1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logmanager</groupId>
+      <artifactId>jboss-logmanager</artifactId>
+      <version>3.0.2.Final</version>
+      <optional>true</optional>
     </dependency>
     <dependency>
       <groupId>io.smallrye.common</groupId>
       <artifactId>smallrye-common-constraint</artifactId>
+      <version>2.1.0</version>
     </dependency>
     <dependency>
       <groupId>org.eclipse.parsson</groupId>
       <artifactId>parsson</artifactId>
+      <version>1.1.2</version>
     </dependency>
   </dependencies>
 
diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultConfiguratorFactory.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultConfiguratorFactory.java
new file mode 100644
index 0000000..2ac5587
--- /dev/null
+++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultConfiguratorFactory.java
@@ -0,0 +1,65 @@
+// SPDX-FileCopyrightText: © 2023 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
+//
+// SPDX-License-Identifier: LGPL-3.0-or-later
+
+package eu.mulk.quarkus.googlecloud.jsonlogging.logmanager;
+
+import eu.mulk.quarkus.googlecloud.jsonlogging.Formatter;
+import java.io.InputStream;
+import java.util.logging.Handler;
+import org.jboss.logmanager.ConfiguratorFactory;
+import org.jboss.logmanager.LogContext;
+import org.jboss.logmanager.LogContextConfigurator;
+import org.jboss.logmanager.handlers.ConsoleHandler;
+
+/**
+ * A convenient {@link ConfiguratorFactory} for JBoss Log Manager.
+ *
+ * <p>You can register this class through the {@link java.util.ServiceLoader} mechanism as a
+ * provider of the {@link ConfiguratorFactory} interface (under the name of {@code
+ * org.jboss.logmanager.ConfiguratorFactory}) to automatically register a {@link ConsoleHandler}
+ * using {@link Formatter} as the default log output method for the application.
+ */
+public final class DefaultConfiguratorFactory implements ConfiguratorFactory {
+
+  private final Handler[] rootHandlers;
+  private final ConfiguratorFactory upstreamConfiguratorFactory;
+
+  /**
+   * Constructs a JBoss Log Manager configuration that uses {@link Formatter} and {@link
+   * ConsoleHandler} for log output.
+   */
+  @SuppressWarnings({"java:S2095", "resource"})
+  public DefaultConfiguratorFactory() {
+    rootHandlers = new Handler[] {createConsoleHandler()};
+    upstreamConfiguratorFactory =
+        new org.jboss.logmanager.configuration.DefaultConfiguratorFactory();
+  }
+
+  /**
+   * Creates a {@link ConsoleHandler} that uses {@link Formatter} for formatting.
+   *
+   * @return a preconfigured {@link ConsoleHandler}.
+   */
+  public static ConsoleHandler createConsoleHandler() {
+    return new DefaultConsoleHandler();
+  }
+
+  @Override
+  public LogContextConfigurator create() {
+    var upstreamConfigurator = upstreamConfiguratorFactory.create();
+    return new LogContextConfigurator() {
+      @Override
+      public void configure(LogContext logContext, InputStream inputStream) {
+        upstreamConfigurator.configure(logContext, inputStream);
+        var logger = logContext.getLogger("");
+        logger.setHandlers(rootHandlers);
+      }
+    };
+  }
+
+  @Override
+  public int priority() {
+    return 50;
+  }
+}
diff --git a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultEmbeddedConfigurator.java b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultEmbeddedConfigurator.java
index e2ad986..79e9288 100644
--- a/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultEmbeddedConfigurator.java
+++ b/core/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/logmanager/DefaultEmbeddedConfigurator.java
@@ -10,7 +10,7 @@
 import org.jboss.logmanager.handlers.ConsoleHandler;
 
 /**
- * A convenient {@link EmbeddedConfigurator} for JBoss Log Manager.
+ * A convenient {@link EmbeddedConfigurator} for JBoss Log Manager Embedded (1.1.x and earlier).
  *
  * <p>You can register this class through the {@link java.util.ServiceLoader} mechanism as a
  * provider of the {@link EmbeddedConfigurator} interface (under the name of {@code
@@ -25,7 +25,7 @@
    * Constructs a JBoss Log Manager configuration that uses {@link Formatter} and {@link
    * ConsoleHandler} for log output.
    */
-  @SuppressWarnings("java:S2095")
+  @SuppressWarnings({"java:S2095", "resource"})
   public DefaultEmbeddedConfigurator() {
     rootHandlers = new Handler[] {createConsoleHandler()};
   }
diff --git a/examples/spring-boot/pom.xml b/examples/spring-boot/pom.xml
index 2940c66..8cb994a 100644
--- a/examples/spring-boot/pom.xml
+++ b/examples/spring-boot/pom.xml
@@ -42,7 +42,7 @@
     <dependency>
       <groupId>org.jboss.slf4j</groupId>
       <artifactId>slf4j-jboss-logmanager</artifactId>
-      <version>1.1.0.Final</version>
+      <version>2.0.1.Final</version>
     </dependency>
     <!-- *** optional ***
     <dependency>
@@ -97,6 +97,11 @@
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
         <version>${spring-boot.version}</version>
+        <configuration>
+          <systemPropertyVariables>
+            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+          </systemPropertyVariables>
+        </configuration>
       </plugin>
     </plugins>
   </build>
diff --git a/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
index a2b824a..77c1f84 100644
--- a/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
+++ b/examples/spring-boot/src/main/java/eu/mulk/quarkus/googlecloud/jsonlogging/example/RootResource.java
@@ -10,9 +10,11 @@
 import org.jboss.logging.Logger;
 import org.jboss.logging.MDC;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-@RestController("/")
+@RestController
+@RequestMapping("/")
 public class RootResource {
 
   static final Logger log = Logger.getLogger(RootResource.class);
diff --git a/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.ConfiguratorFactory b/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.ConfiguratorFactory
new file mode 100644
index 0000000..c4b4beb
--- /dev/null
+++ b/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.ConfiguratorFactory
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: © 2023 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# For JBoss Log Manager 3.x (or JBoss Log Manager Embedded 1.2 or later)
+eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultConfiguratorFactory
diff --git a/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.EmbeddedConfigurator b/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.EmbeddedConfigurator
index 6d937e5..b9ffbe2 100644
--- a/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.EmbeddedConfigurator
+++ b/examples/spring-boot/src/main/resources/META-INF/services/org.jboss.logmanager.EmbeddedConfigurator
@@ -1 +1,6 @@
+# SPDX-FileCopyrightText: © 2023 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# For JBoss Log Manager Embedded 1.1.x and earlier.
 eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultEmbeddedConfigurator
diff --git a/examples/spring-boot/src/main/resources/logging.properties b/examples/spring-boot/src/main/resources/logging.properties
index 31aebd7..8bc0033 100644
--- a/examples/spring-boot/src/main/resources/logging.properties
+++ b/examples/spring-boot/src/main/resources/logging.properties
@@ -2,5 +2,11 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-handlers = eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultConsoleHandler
-.level = INFO
+# java.util.logging properties
+#handlers = eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultConsoleHandler
+#.level = INFO
+
+# JBoss Log Manager properties
+logger.level = INFO
+logger.handlers = GOOGLEJSON
+handler.GOOGLEJSON = eu.mulk.quarkus.googlecloud.jsonlogging.logmanager.DefaultConsoleHandler