Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3424

JDBC Appender configuration properties not handled correctly after upgrading to 2.17.2

    XMLWordPrintableJSON

Details

    • Dependency upgrade
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.17.2
    • 2.18.0
    • Appenders, Configuration
    • None

    Description

      I'm a maintainer of Pax Logging project and for long time we had this configuration in integration tests:

      appender.jdbc.type = JDBC
      appender.jdbc.name = jdbc
      appender.jdbc.tableName = LOG
      appender.jdbc.connectionSource.type = DriverManager
      appender.jdbc.connectionSource.driverClassName = org.h2.Driver
      appender.jdbc.connectionSource.connectionString = jdbc:h2:tcp://localhost:PORT/logsdb
      appender.jdbc.connectionSource.p1.type = property
      appender.jdbc.connectionSource.p1.name = SCHEMA
      appender.jdbc.connectionSource.p1.value = logs
      appender.jdbc.connectionSource.p2.type = property
      appender.jdbc.connectionSource.p2.name = QUERY_TIMEOUT
      appender.jdbc.connectionSource.p2.value = 5000
      appender.jdbc.connectionSource.p3.type = property
      appender.jdbc.connectionSource.p3.name = user
      appender.jdbc.connectionSource.p3.value = logadmin
      appender.jdbc.connectionSource.p4.type = property
      appender.jdbc.connectionSource.p4.name = password
      appender.jdbc.connectionSource.p4.value = logpassword
      appender.jdbc.c1.type = Column
      appender.jdbc.c1.name = DATE
      appender.jdbc.c1.isEventTimestamp = true
      appender.jdbc.c2.type = Column
      appender.jdbc.c2.name = LEVEL
      appender.jdbc.c2.pattern = %level
      appender.jdbc.c2.isUnicode = false
      appender.jdbc.c3.type = Column
      appender.jdbc.c3.name = SOURCE
      appender.jdbc.c3.pattern = %logger
      appender.jdbc.c3.isUnicode = false
      appender.jdbc.c4.type = Column
      appender.jdbc.c4.name = MESSAGE
      appender.jdbc.c4.pattern = %message
      appender.jdbc.c4.isUnicode = false
      
      rootLogger.level = info
      rootLogger.appenderRef.console.ref = console
      logger.my.name = my.logger
      logger.my.level = trace
      logger.my.additivity = false
      logger.my.appenderRef.jdbc.ref = jdbc
      

      now the properties are not handled correctly. For example with:

      appender.jdbc.connectionSource.p1.type = property
      appender.jdbc.connectionSource.p1.name = SCHEMA
      appender.jdbc.connectionSource.p1.value = logs
      

      I'm getting (in org.apache.logging.log4j.core.config.plugins.util.PluginBuilder#generateParameters()):

      createProperty(name="SCHEMA", value="logs", value="null")
      

      call and org.apache.logging.log4j.core.config.Property#createProperty(java.lang.String, java.lang.String, java.lang.String) is called with:

      • SCHEMA
      • logs
      • null
        values.

      In debug logs there's:

      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : createProperty(name="password", value="logpassword", value="null")
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : createProperty(name="SCHEMA", value="logs", value="null")
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : createProperty(name="user", value="logadmin", value="null")
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : Building Plugin[name=property, class=org.apache.logging.log4j.core.config.Property].
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : createProperty(name="QUERY_TIMEOUT", value="5000", value="null")
      org.ops4j.pax.logging.pax-logging-api [log4j2] DEBUG : Building Plugin[name=connectionSource, class=org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource].
      

      2.17.2 introduced org.apache.logging.log4j.core.config.Property#rawValue and my values are available under rawValue instead of value fields of org.apache.logging.log4j.core.config.Property objects.

      Eventually org.apache.logging.log4j.core.appender.db.jdbc.AbstractDriverManagerConnectionSource#toProperties() takes the value from Property and it is null...

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              ggrzybek Grzegorz Grzybek
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: