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

Unable to set string properties to json strings with nested nodes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.3.0-alpha3
    • Component/s: logback-core
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: