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

CompositeConverters children are not given Context

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • 1.3.0-alpha14
    • 1.2.6
    • logback-core
    • None

    Description

      I encountered this bug with 1.2.6, however it's possible other versions are affected as well.

       

      With a logback.xml configuration like this:

      <configuration>
          <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
              <encoder>
                  <pattern>[%thread] %-5level - %msg%n%replace(%rootException{5
                      , sun.reflect
                      , java.lang
                      , java.util
                      , org.gradle
                      , com.sun
                      , org.junit}){'\\n', '~~'}%nopexception</pattern>
              </encoder>
          </appender>
      
          <logger name="test" level="debug" additivity="false">
              <appender-ref ref="STDOUT"/>
          </logger>
          <root level="error">
              <appender-ref ref="STDOUT"/>
          </root>
      </configuration>
      

       

      Logback throws a NullPointerException on startup:

      10:52:50,790 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:19 - RuntimeException in Action for tag [encoder] java.lang.NullPointerException10:52:50,790 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:19 - RuntimeException in Action for tag [encoder] java.lang.NullPointerException at java.lang.NullPointerException at  at ch.qos.logback.classic.pattern.ThrowableProxyConverter.start(ThrowableProxyConverter.java:75) 
      at  at ch.qos.logback.core.pattern.ConverterUtil.startConverters(ConverterUtil.java:37) 
      at  at ch.qos.logback.core.pattern.ConverterUtil.startConverters(ConverterUtil.java:33) 
      at  at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:89) 
      at  at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28)

       

      I created this sample project to demonstrate the above error. I also took a stab at fixing the issue with this pull request.

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            billkoch Bill Koch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: