You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "krallus (via GitHub)" <gi...@apache.org> on 2024/08/06 21:18:47 UTC
Re: [PR] Expanded more elements to Log4j-config.xsd (logging-log4j2)
krallus commented on PR #1441:
URL: https://github.com/apache/logging-log4j2/pull/1441#issuecomment-2272170491
Thank you. I ran into a some problems using the new one at https://logging.apache.org/xml/ns/.
Here is a simple `log4j2.xml`:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration>
<Configuration xmlns="https://logging.apache.org/xml/ns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-config-2.xsd"
status="WARN">
<Properties>
<Property name="root.logging.level">${sys:myapp.root.logging.level:-${sys:rootLogger.level:-WARN}}</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%date{ABSOLUTE} %class %method - %message%n%throwable" />
</Console>
</Appenders>
<Loggers>
<Root level="${root.logging.level}">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
```
The new XSD incorrectly points out two problems:
1. It doesn't like the way I've set the value for a Property: as content. However, that is one of the ways shown in the example at https://logging.apache.org/log4j/2.x/manual/configuration.html#concise-syntax. Currently, it will only validate if I set the value using the `value` attribute.
2. More significantly, it does not accept "${root.logging.level}" for Root's `level`, which is using [Property Substitution](https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution).
Note that the use case for the way I've written the above configuration is that if I start my Java Virtual Machine with `-Dmyapp.root.logging.level=DEBUG` (or some other level), it will use that for the root logger if it is set, otherwise it defaults to WARN.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org