0
votes

I have the following file appender

log4j.appender.file.File=${myFileLoc}/log/mylog.log

However, I want to make sure it still functions properly if someone forgets to set the system property. Is there a way to specify a default value in the properties file?

I do not want to change the log4j.xml in any way. I just want to change the log4j properties file or if possible, make some code change to reflect what i need.

For example, if possible, i can check for the system property in the code and if it is not set, then pass the default value to the logger. Is that feasible?

1
I'm just trying to clearly understand this questions. Are you using both xml file and properties file ? - Rajind Ruparathna
i dont have access to the log4j xml file. i can only work with the log4j.properties file - AbtPst

1 Answers

0
votes

I think you can define it like this in properties file. See here.

property.myFileLoc = target/rolling/rollingtest.log

For property substitution in xml file see here. Also please refer to this answer.