ppkarwasz commented on issue #3358: URL: https://github.com/apache/logging-log4j2/issues/3358#issuecomment-2572901859
The YAML features that you can use in a Log4j configuration depend on the features supported by the parser we use. Since the [Jackson YAML data format module](https://github.com/FasterXML/jackson-dataformats-text/blob/master/yaml) does not support the [`<<` merge key YAML extension](https://yaml.org/type/merge.html), you can not use it in a Log4j configuration file. Log4j will automatically support merge keys, if FasterXML/jackson-dataformats-text#171 is ever implemented. If you wish to use merge keys in a Log4j configuration file consider: - contributing a PR to the Jackson project that solves FasterXML/jackson-dataformats-text#171. This is the **preferred** solution, since it does not require a change to the tree parser used by Log4j. - or contributing an [`AbstractConfiguration`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/config/AbstractConfiguration.html) implementation to Log4j that is based on [SnakeYAML](https://bitbucket.org/snakeyaml/snakeyaml/src/master/), which is the low-level parser used by Jackson. Since adding an additional **direct** dependency to Log4j has security implications, please discuss it on the [`d...@logging.apache.org` mailing list](https://logging.apache.org/support.html#discussions-maintainer) first, if you choose this way. **Remark**: Regardless of the support for merge keys, your configuration file would not work, since `RollingFileTemplate` is not a valid configuration snippet: it lacks the **required** `name`, `fileName` and `filePattern` attributes. This will always result in a configuration error, because Log4j Core interprets **all** the children of `Appenders` as appender definitions. You should use something like this instead (again: assuming merge keys are supported by `jackson-dataformat-yaml`, which is **not** the case right now): ```yaml RollingFile: - &template name: FOO_LOG fileName: logs/foo.log filePattern: logs/foo.%i.log.gz ignoreExceptions: false PatternLayout: pattern: "%d [%t] %-5p %c{1.} - %m%n" Policies: SizeBasedTriggeringPolicy: size: "50 MB" DefaultRolloverStrategy: max: 200 - <<: *template name: BAR_LOG fileName: logs/bar.log filePattern: logs/bar.%i.log.gz ``` -- 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-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org