Skip to content

appenderRefs in v1 properties files not handled correctly #213

@rschmitt

Description

@rschmitt

Converting this file from v1:properties to v2:xml produces invalid configuration:

$ java -jar ~/Downloads/log4j-transform-cli.jar config-file convert -i v2:properties -o v2:xml log4j-core-test/src/test/resources/log4j-rolling.properties output.xml
<?xml version="1.0" ?>
<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" name="PropertiesConfigTest" status="error">
  <Properties>
    <Property name="filename" value="target/rolling/rollingtest.log"/>
  </Properties>
  <ThresholdFilter level="debug"/>
  <Appenders>
    <Console name="STDOUT">
      <PatternLayout pattern="%m%n"/>
    </Console>
    <RollingFile fileName="${filename}" filePattern="target/rolling2/test1-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz" name="RollingFile">
      <Policies>
        <TimeBasedTriggeringPolicy interval="2" modulate="true"/>
        <SizeBasedTriggeringPolicy size="100MB"/>
      </Policies>
      <PatternLayout pattern="%d %p %C{1.} [%t] %m%n"/>
    </RollingFile>
    <List filters="threshold" name="List">
      <ThresholdFilter level="error"/>
    </List>
  </Appenders>
  <Loggers>
    <Root appenderRefs="stdout" level="info">
      <AppenderRef ref="STDOUT"/>
    </Root>
    <Logger additivity="false" appenderRefs="rolling" level="debug" name="org.apache.logging.log4j.core.appender.rolling">
      <AppenderRef ref="RollingFile"/>
    </Logger>
  </Loggers>
</Configuration>

This results in a runtime warning:

    [junit] 2025-08-04T21:49:33.638Z main ERROR Root contains an invalid element or attribute "appenderRefs"

I assume that rootLogger.appenderRefs=... is valid Log4j2 properties config syntax, since it appears in Log4j2's test corpus as well as various Google search results (example).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions