Skip to content

Moqui now honors the standard Log4j property 'log4j.configurationFile'#706

Open
jmochel wants to merge 1 commit intomoqui:masterfrom
jmochel:reconfigure-logging-from-standard-log4j-override
Open

Moqui now honors the standard Log4j property 'log4j.configurationFile'#706
jmochel wants to merge 1 commit intomoqui:masterfrom
jmochel:reconfigure-logging-from-standard-log4j-override

Conversation

@jmochel
Copy link
Copy Markdown

@jmochel jmochel commented Mar 21, 2026

Intention:

To give developers the same level of control during logging of components and the framework they have in other products using Log4j.

What it does:

This change replaces the use of the hard coded log4j.xml from the jar resources with

  1. A use of the contents of the standard Log4J configuration file override property (log4j.configurationFile) from system properties or environment variables if it is set in either.
  2. If no location is found, it tries to find "log4j2.xml" on the classpath (basically, as a resource bundled with the code or libraries).
  3. If it can't find a configuration file in either location, it logs a warning and stops (does not attempt to reconfigure

@eigood
Copy link
Copy Markdown
Contributor

eigood commented Mar 27, 2026

It might be nice to see several layers of initialization. The initial bootstrap, where a very simple log4j config is loaded. Then, after all MoquiConf.xml snippets are loaded and merged, it(log4j) gets re-initialized.

@schue
Copy link
Copy Markdown

schue commented Mar 27, 2026

Typically log4j.configurationFile allows multiple files separated by commas.

If the file doesn't exist it will still try to load the file. A File.exists() that logs a warning if it isn't there would be more defensive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants