Reputation: 167
i would like to turn of my debug statements at runtime in log4j2. According to the documentation we can do this. I kept my log4j.xml file in default package and then made jar out of it. Since I cannot modify jar i specified xml file using Dlog4j.configuration=/path/to/log4j.xml. However,this is not working. I Tried everything using file:// uri to all the combination, still it is not picking the xml.
Upvotes: 6
Views: 6941
Reputation: 550
Following must be added to configuration file:
<Configuration monitorInterval="60" >
Upvotes: 1
Reputation: 36754
The system property to specify the config file location is different from log4j-1.x. In log4j2, the property is "log4j.configurationFile".
So if the config is in a jar file you would use:
-Dlog4j.configurationFile=jar:file:///C:/path/to/jarfile.jar!/path/to/log4j2.xml
(I assume you have the monitorInterval
set in your configuration as documented here: http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticReconfiguration)
Upvotes: 3