Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1047,10 +1047,19 @@ private static void configureLogger() {
setSystemPropertyDefault(
SIMPLE_LOGGER_DATE_TIME_FORMAT_PROPERTY, SIMPLE_LOGGER_DATE_TIME_FORMAT_DEFAULT);

String logLevel;
if (isDebugMode()) {
setSystemPropertyDefault(SIMPLE_LOGGER_DEFAULT_LOG_LEVEL_PROPERTY, "DEBUG");
} else if (!isFeatureEnabled(AgentFeature.STARTUP_LOGS)) {
setSystemPropertyDefault(SIMPLE_LOGGER_DEFAULT_LOG_LEVEL_PROPERTY, "WARN");
logLevel = "DEBUG";
} else {
logLevel = ddGetProperty("dd.log.level");
}

if (null == logLevel && !isFeatureEnabled(AgentFeature.STARTUP_LOGS)) {
logLevel = "WARN";
}

if (null != logLevel) {
setSystemPropertyDefault(SIMPLE_LOGGER_DEFAULT_LOG_LEVEL_PROPERTY, logLevel);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public static void onEnter() {
GlobalLogLevelSwitcher.get().switchLevel(LogLevel.DEBUG);
configLogger.debug("New instance: {}", Config.get());
}
} else {
String logLevel = Config.get().getLogLevel();
if (null != logLevel) {
GlobalLogLevelSwitcher.get().switchLevel(LogLevel.fromString(logLevel));
}
}

datadog.trace.agent.tooling.nativeimage.TracerActivation.activate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class GeneralConfig {
@Deprecated // Use dd.tags instead
public static final String GLOBAL_TAGS = "trace.global.tags";

public static final String LOG_LEVEL = "log.level";
public static final String TRACE_DEBUG = "trace.debug";
public static final String TRACE_TRIAGE = "trace.triage";
public static final String TRIAGE_REPORT_TRIGGER = "triage.report.trigger";
Expand Down
9 changes: 9 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
import static datadog.trace.api.config.GeneralConfig.HEALTH_METRICS_ENABLED;
import static datadog.trace.api.config.GeneralConfig.HEALTH_METRICS_STATSD_HOST;
import static datadog.trace.api.config.GeneralConfig.HEALTH_METRICS_STATSD_PORT;
import static datadog.trace.api.config.GeneralConfig.LOG_LEVEL;
import static datadog.trace.api.config.GeneralConfig.PERF_METRICS_ENABLED;
import static datadog.trace.api.config.GeneralConfig.PRIMARY_TAG;
import static datadog.trace.api.config.GeneralConfig.RUNTIME_ID_ENABLED;
Expand Down Expand Up @@ -906,6 +907,7 @@ static class HostNameHolder {

private final boolean traceAgentV05Enabled;

private final String logLevel;
private final boolean debugEnabled;
private final boolean triageEnabled;
private final String triageReportTrigger;
Expand Down Expand Up @@ -2038,6 +2040,7 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())

servletAsyncTimeoutError = configProvider.getBoolean(SERVLET_ASYNC_TIMEOUT_ERROR, true);

logLevel = configProvider.getString(LOG_LEVEL);
debugEnabled = configProvider.getBoolean(TRACE_DEBUG, false);
triageEnabled = configProvider.getBoolean(TRACE_TRIAGE, instrumenterConfig.isTriageEnabled());
triageReportTrigger = configProvider.getString(TRIAGE_REPORT_TRIGGER);
Expand Down Expand Up @@ -3441,6 +3444,10 @@ public boolean isTraceAgentV05Enabled() {
return traceAgentV05Enabled;
}

public String getLogLevel() {
return logLevel;
}

public boolean isDebugEnabled() {
return debugEnabled;
}
Expand Down Expand Up @@ -4626,6 +4633,8 @@ public String toString() {
+ xDatadogTagsMaxLength
+ ", traceAgentV05Enabled="
+ traceAgentV05Enabled
+ ", logLevel="
+ logLevel
+ ", debugEnabled="
+ debugEnabled
+ ", triageEnabled="
Expand Down