Test for customlogmanager=false
MODIFY
dd-java-agent/src/test/groovy/datadog/trace/agent/CustomLogManagerTest.groovy
dd-java-agent/src/test/groovy/datadog/trace/agent/CustomLogManagerTest.groovy
@@ -69,4 +69,13 @@ class CustomLogManagerTest extends Specification {
, ["JBOSS_HOME": "/"]
, true) == 0
}
+
+ def "jmxfetch startup in premain forced by customlogmanager=false"() {
+ expect:
+ IntegrationTestUtils.runOnSeparateJvm(LogManagerSetter.getName()
+ , [agentArg, "-Ddd.jmxfetch.enabled=true", "-Ddd.jmxfetch.refresh-beans-period=1", "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=off", "-Ddd.app.customlogmanager=false", "-Djava.util.logging.manager=jvmbootstraptest.CustomLogManager"] as String[]
+ , "" as String[]
+ , ["JBOSS_HOME": "/"]
+ , true) == 0
+ }
}

MODIFY
dd-java-agent/src/test/java/jvmbootstraptest/LogManagerSetter.java
dd-java-agent/src/test/java/jvmbootstraptest/LogManagerSetter.java
@@ -4,7 +4,22 @@ import java.util.logging.LogManager;
public class LogManagerSetter {
public static void main(final String... args) throws Exception {
- if (System.getProperty("java.util.logging.manager") != null) {
+ if (System.getProperty("dd.app.customlogmanager") != null) {
+ if (Boolean.valueOf(System.getProperty("dd.app.customlogmanager"))) {
+ System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
+ customAssert(
+ LogManager.getLogManager().getClass(),
+ LogManagerSetter.class
+ .getClassLoader()
+ .loadClass(System.getProperty("java.util.logging.manager")),
+ "Javaagent should not prevent setting a custom log manager");
+ } else {
+ customAssert(
+ isJmxfetchStarted(),
+ true,
+ "jmxfetch should start in premain when customlogmanager=false.");
+ }
+ } else if (System.getProperty("java.util.logging.manager") != null) {
if (ClassLoader.getSystemResource(System.getProperty("java.util.logging.manager")) == null) {
customAssert(
isJmxfetchStarted(),
@@ -25,15 +40,6 @@ public class LogManagerSetter {
true,
"jmxfetch should start in premain when custom log manager found on classpath.");
}
- } else if (System.getProperty("dd.app.customlogmanager") != null) {
- System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
- customAssert(
- LogManager.getLogManager().getClass(),
- LogManagerSetter.class
- .getClassLoader()
- .loadClass(System.getProperty("java.util.logging.manager")),
- "Javaagent should not prevent setting a custom log manager");
-
} else if (System.getenv("JBOSS_HOME") != null) {
System.setProperty("java.util.logging.manager", CustomLogManager.class.getName());
customAssert(

Test for customlogmanager=false