Persimmonium
Persimmonium

Reputation: 15789

is it possible to log how the jvm was called (including all -D -Xmx etc)

In order to facilitate troubleshooting, I would like to log to our log files exactly how the java process was invoked.

This should ideally include:

Is there a way to do this?

EDIT: I NEED to do this from inside java, not outside

Upvotes: 0

Views: 311

Answers (2)

Joachim Sauer
Joachim Sauer

Reputation: 308259

Use RuntimeMXBean.getInputArguments():

List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();

This will only return arguments that are passed to the JVM during initialization.

Further information might be found with the other methods of RuntimeMXBean, such as getClassPath(), getVmName(), ...

Upvotes: 3

GuruKulki
GuruKulki

Reputation: 26428

You have a batch file which starts your application and have the echo statements to print the details you listed above.

For example have a ENV VAR as JAVA_OPTS then set the value for it as below

set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m -XX:MaxPermSize=256m -Xms128m -Xmx1024m

Once it is set use the echo statements like below to print the details.

echo   JAVA_OPTS: %JAVA_OPTS%

Upvotes: 0

Related Questions