For an application which is deployed on a large number of machines I took the decision to deploy a standard log4j.xml file with the application package, just to make sure that have the same settings are present everywhere : appenders, categories, levels.
This does have the downside that when modifying the levels locally we risk losing the changes on re-deploy or living with old settings. In practice, the only thing we need to change are the logger levels, most of the time 1 of them, so I’m looking for a solution which allows me to override just the levels per-installation.
How can I override the log4j levels without changing the original log4j.xml file?
If you still want to have a shared main configuration, you could consider adding something to the application that allowed the Log4J logger levels to be changed after initialization. You could invoke these changes either via JMX, getting the overrides from a centralized source, or simply by periodically reading a local installation-specific override file (if present), depending on what infrastructure support your application can rely on.
Take a look at this for some more information: