Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1101

Unable to set string properties to json strings with nested nodes

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 1.3.0-alpha3
    • 1.1.3
    • logback-core
    • None

    Description

      I have an appender that has a string property. I would like that property to be in a JSON string format.

      However, due to a parsing logic error, logback's variable substitution logic for strings will remove the last right curly brace from the string. This prevents me from being able to use a JSON string property.

      For example, if the logback.xml contains:

          <appender name="xxx" class="TestAppender">
              <testProperty>{"hello":{"world":"yay"}}</testProperty>
          </appender>
      

      And the TestAppender class contains:

          public void setTestProperty(String testProperty) {
              //...
          }
      

      I expect logback to pass the following string to the setTestProperty method:

      {"hello":{"world":"yay"}}
      

      However, logback incorrectly strips off the trailing right curly brace, and instead passes the following string

      {"hello":{"world":"yay"}
      

      I have attached a project that demonstrates the behavior.

      To run the test, execute the following:

      mvn clean package
      java -cp target/substitution-test-1.0-SNAPSHOT.jar Main
      

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            philsttr Phil
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: