Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variables and system properties to the self-diagnostics #2737

Merged
merged 6 commits into from
Dec 1, 2022
Merged
Changes from 2 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 @@ -32,6 +32,7 @@
import java.lang.management.RuntimeMXBean;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Properties;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -101,9 +102,11 @@ public void init() {
}

if (startupLogger.isDebugEnabled()) {
startupLogger.debug("OS: " + System.getProperty("os.name"));
startupLogger.trace("OS: " + System.getProperty("os.name"));
logJavaInfo();
startupLogger.debug("Netty versions: " + NettyVersions.extract());
startupLogger.trace("Netty versions: " + NettyVersions.extract());
startupLogger.trace("Env: " + System.getenv());
startupLogger.trace("System properties: " + findSystemProperties());
}

} catch (Exception e) {
Expand All @@ -112,11 +115,25 @@ public void init() {
}

private static void logJavaInfo() {
startupLogger.debug("Classpath: " + System.getProperty("java.class.path"));
startupLogger.debug(
startupLogger.trace("Classpath: " + System.getProperty("java.class.path"));
startupLogger.trace(
"Input arguments: " + ManagementFactory.getRuntimeMXBean().getInputArguments());
startupLogger.debug("_JAVA_OPTIONS: " + System.getenv("_JAVA_OPTIONS"));
startupLogger.debug("JAVA_TOOL_OPTIONS: " + System.getenv("JAVA_TOOL_OPTIONS"));
startupLogger.trace("_JAVA_OPTIONS: " + System.getenv("_JAVA_OPTIONS"));
startupLogger.trace("JAVA_TOOL_OPTIONS: " + System.getenv("JAVA_TOOL_OPTIONS"));
trask marked this conversation as resolved.
Show resolved Hide resolved
}

private static String findSystemProperties() {
Properties properties = System.getProperties();
StringBuilder propsBuilder = new StringBuilder();
properties.forEach(
(key, value) -> {
boolean firstProperty = propsBuilder.length() == 0;
if (!firstProperty) {
propsBuilder.append(", ");
}
propsBuilder.append("(" + key + "=" + value + ")");
});
return propsBuilder.toString();
}

@Override
Expand Down