File tree Expand file tree Collapse file tree
agent/entrypoint/src/main/java/co/elastic/otel/agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public class ElasticAgent {
2626
2727 private static final String OTEL_JAVAAGENT_LOGGING = "otel.javaagent.logging" ;
2828 private static final String OTEL_JAVAAGENT_LOGGING_ENV = "OTEL_JAVAAGENT_LOGGING" ;
29+ private static final String OTEL_JAVAAGENT_LOGGING_DEFAULT = "simple" ;
2930
3031 /**
3132 * Entry point for -javaagent JVM argument attach
@@ -60,15 +61,20 @@ public static void main(String[] args) {
6061
6162 private static void initLogging () {
6263
63- // do not override explicitly provided configuration
64- if (System .getProperty (OTEL_JAVAAGENT_LOGGING ) != null
65- || System .getenv (OTEL_JAVAAGENT_LOGGING_ENV ) != null ) {
64+ // Do not override explicitly provided configuration unless it's using the default as the
65+ // 'simple' provider is not included in this distribution and that triggers an SLF4j error.
66+ if (isLoggingNotDefault (System .getProperty (OTEL_JAVAAGENT_LOGGING ))
67+ || isLoggingNotDefault (System .getenv (OTEL_JAVAAGENT_LOGGING_ENV ))) {
6668 return ;
6769 }
6870
6971 // must match value returned by ElasticLoggingCustomizer#getName
7072 System .setProperty (OTEL_JAVAAGENT_LOGGING , "elastic" );
7173 }
7274
75+ private static boolean isLoggingNotDefault (String value ) {
76+ return value != null && !OTEL_JAVAAGENT_LOGGING_DEFAULT .equals (value );
77+ }
78+
7379 private ElasticAgent () {}
7480}
You can’t perform that action at this time.
0 commit comments