Re: log4j initialization does not seem to happen when Tomcat service is started
"Piotr P. Karwasz" <[email protected]> Sun, 31 Mar 2024 22:49:22 +0200
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <CAFmygFYz41k6cgAX0s-U7+7=q3n8t6A7KSBZnZgqnKF7uiD_bg@mail.gmail.com> |
Hi Piers, On Wed, 20 Mar 2024 at 17:09, Piers Uso Walter <[email protected]> wrote: > Am I trying something unusual here when I attempt to make the app decide where the log4j configuration file is located? > Is there any other way in which I can achieve this? > Is there an API for this? Sorry for the late answer. There are two solutions I could think of: 1. You could use a custom system variable (e.g. `ilink.log4j2.configurationFile` and place: <context-param> <param-name>log4jConfiguration</param-name> <param-value>${sys:ilink.log4j2.configurationFile:-classpath:path_to_default_config_file</param-value> </context-param> 2. You could write container specific documentation: * Tomcat supports the possibility to override context parameters in an appropriate `context.xml` file: https://tomcat.apache.org/tomcat-9.0-doc/config/index.html * I don't have too much experiance with JBoss, but it supports variable substitution in web descriptors and you could use a `jboss-web.xml` file to prevent Tomcat from using it. Piotr