On Fri, Apr 16, 2021 at 02:21:53AM -0700, Mark van Rossum wrote:
> Hi,
> I'm using the default cas-overlay template which includes a log4j2.xml
> config file. This has a value: "
> <Property name="cas.log.level">info</Property>" which can be altered to set
> the main logging level.
>
> I have all other settings in cas.properties, and then multiple environments
> (dev,preprod,prod) etc using their own property files which overlay the
> cas.properties with environment specific values
>
> I'd like to keep the log4j XML file common across all my environments, but
> set the log level differently per environment, using the property files.
>
> I tried setting "cas.log.level" in the property file but this just errored:
> "Failed to bind properties under 'cas' to
> org.apereo.cas.configuration.CasConfigurationProperties
> cas.log.level = TRACE"
Apparently 'CasConfigurationProperties' is not an extension of
Properties, but rather something which knows only a specific set of
properties.
> Weirdly it seems you can set this property on the command line with
> "-Dcas.log.level" though, but I'd prefer to keep all environment specific
> settings in it's property file as it makes configuration much simpler.
That makes me wonder if CAS is copying the values of System.properties
to Log4J somehow. It does seem to be handling Log4J setup itself
rather than letting Log4J use its own configuration discovery
mechanisms.
> It seems like a common thing to do, is there anyway to set this value using
> the property files? The documentation [1] notes you can set "logging.level="
> in the property files, but you would then need to duplicate all the loggers
> from the log4j XML file which.
The behavior you've reported suggests that there is no way to do that.
You could try XInclude:
https://logging.apache.org/log4j/2.x/manual/configuration.html#XInclude
You'd need an additional per-instance XML document, to use XInclude.
That would at least keep it alongside the other configuration data.
OTOH you might consider logging configuration to be an attribute of
the deployment rather than of the instance, and set that value using
JNDI. Environment objects are easily set up in Tomcat; I don't know
other containers well enough to comment on them.
I would recommend a thorough reading of that whole page.
--
Mark H. Wood
Lead Technology Analyst
University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202
317-274-0749
www.ulib.iupui.edu