Have you considered using log4j.properties instead of log4j.xml? The properties version accepts variable substitution for the values.
You can create your own properties inside the log4j.properties file (someProp=value
) and later use ${someProp
} to get the value.
From what I remember (not sure though :D) you can also have this in the log4j.xml file but the variables must be defined as system variables (-DsomeProp=value
) and in your log4j.xml you again use ${someProp}
. This version though is a little messy because you do not have the params declared in the same place you are using them, as you do in log4j.properties.