-
Notifications
You must be signed in to change notification settings - Fork 36
Log Environment Settings on Start Up
Milton Smith edited this page Nov 11, 2016
·
1 revision
In the event your application crashes or a security incident it's useful to see the exact command line options that started your program, shell environment variable values, and Java System Properties. All these settings may impact your program positively or negatively. Logging these when your application starts is very simple,
logger.info("Print some sample command line arguments.");
String[] fakeargs = new String[4];
fakeargs[0] = "arg0";
fakeargs[1] = "arg1";
fakeargs[2] = "arg2";
fakeargs[3] = "arg3";
SecurityUtil.logCommandLineArguments(fakeargs);
logger.info("Print shell environment variables.");
SecurityUtil.logShellEnvironmentVariables();
logger.info("Print Java system properties.");
SecurityUtil.logJavaSystemProperties();