I was reading the following section in the logback manual: https://logback.qos.ch/manual/configuration.html#variableSubstitution
I'm using logback v2.9.1 and v6.1 of logstash-logback-encoder.
I have a situation where I'm defining an encoder with a "providers" element, and in that I'm setting the "stackTrace" element, and the "throwableConverter". I set the "rootCauseFirst" property. Right now I'm setting it to a static value, but I'm experimenting with setting it from a property.
In my test case, I clearly see the difference between setting a static value of "true" vs. "false". However, if I define a "ROOT_CAUSE_FIRST" variable before the appender definition, with a value of either "true" or "false", and reference "${ROOT_CAUSE_FIRST}" in the "rootCauseFirst" setting, the result is that it doesn't log the exception at all. I don't see it in the log.
The following is an elided copy of my logback.xml:
<configuration scan="true" scanPeriod="5 seconds" debug="true">
<variable name="ROOT_CAUSE_FIRST" value="false"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
...
<stackTrace>
<fieldName>exTrace</fieldName>
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>10</maxDepthPerThrowable>
<!-- <rootCauseFirst>${ROOT_CAUSE_FIRST}</rootCauseFirst> -->
<rootCauseFirst>true</rootCauseFirst>
<maxLength>10240</maxLength>
</throwableConverter>
</stackTrace>
<stackHash>
<fieldName>exHash</fieldName>
</stackHash>
<sequence>
<fieldName>seq</fieldName>
</sequence>
<pattern><pattern>{ "format": "nf-v1.0" }</pattern></pattern>
</providers>
</encoder>
</appender>
...
</configuration>
What is shown here is the "static" version, and the line with the variable ref is commented out. As I said earlier, this appears to work fine, but if I reverse the comments, it simply doesn't log the exception at all.