This is a bit of a weird request but I am trying to set some jvmargs in the log4j.properties file. At present I use ant to for example set some args....
jvmarg value="-Dmail.smtp.socketFactory.port=465"
... but it would be great to group a few of these logging relevant arguments into the .properties file. Does anyone know how to do this?
Thanks in advance!
If the properties can be added after JVM startup, you could add a property to your properties file that lists all properties that you want to add to the SystemProperties
collection, something like:
# property names of system properties
systemprops=mail.smtp.port mail.smtp.socketFactory.class
mail.smtp.port=465
mail.smtp.socketFactory.class=some.class
Your startup code can read the systemprops value, split on whitespace and add the resulting list of properties to the SystemProperties
collection while reading the values from your properties collection.
This way your code does not need to know which properties to add to system props, only that the properties to add are defined by the systemprops property.