Skip to content

Log4j2 yml config do not support YAML Anchors and Aliases #3358

@darkSheep404

Description

@darkSheep404

Description

Log4j2 yml config do not support YAML Anchors and Aliases with error Logger contains an invalid element or attribute "<<"

Configuration:
  status: WARN
  Appenders:
    RollingFileTemplate: &RollingFileTemplate
      ignoreExceptions: false
      PatternLayout:
        pattern: "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%X{traceId},%X{spanId}] [%pid] [%thread] %-5level %X{class}.%M - %msg%n"
      Policies:
        SizeBasedTriggeringPolicy:
          size: "50 MB"
      DefaultRolloverStrategy:
        max: 200
    RollingFile:
      - name: XX_LOGGER_LOG
        fileName: ./logs/xx/${env:HOSTNAME:-}/app/app.log
        filePattern: "./logs/xx/${env:HOSTNAME:-}/app/app_%d{yyyy}-%i.log.gz"
        <<: *RollingFileTemplate
  Loggers:
    Root:
      level: INFO
      AppenderRef:
        - ref: CONSOLE_OUT_APPENDER
        - ref: XX_LOGGER_LOG

main ERROR Unable to locate plugin for LoggerTemplate
2025-01-06T08:35:01.514260458Z 2025-01-06 08:35:01,514 main ERROR Logger contains an invalid element or attribute "<<"
2025-01-06T08:35:01.514794013Z 2025-01-06 08:35:01,514 main ERROR Logger contains an invalid element or attribute "<<"
2025-01-06T08:35:01.515709563Z 2025-01-06 08:35:01,515 main ERROR Logger contains an invalid element or attribute "<<"
2025-01-06T08:35:01.516202917Z 2025-01-06 08:35:01,516 main ERROR Logger contains an invalid element or attribute "<<"
2025-01-06 08:35:01,516 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.config.LoggersPlugin for element Loggers: java.lang.NullPointerException 

Configuration

Version: [2.18.0]

Operating system: [redheat]

JDK: [JDK 8 ]

Logs

[Stacktraces, errors, etc. relevant applications logs.]

Reproduction


[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions