<div dir="ltr">Sorry, I forgot the other question you asked. We're using logback 1.2.9.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 9, 2023 at 10:28 AM David Karr <<a href="mailto:davidmichaelkarr@gmail.com">davidmichaelkarr@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I actually think I've gotten something that will work, although I have another question related to this that I think I'll post in a separate question.<div><br></div><div>In our "baselogback.xml", I will change this:</div><div><br></div><div>                <stackTrace><br>                    <fieldName>exTrace</fieldName><br>                    <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter"><br>                        <maxDepthPerThrowable>10</maxDepthPerThrowable><br>                        <rootCauseFirst>false</rootCauseFirst><br>                        <maxLength>10240</maxLength><br>                    </throwableConverter><br>                </stackTrace><br><br>To:<br><br>                <stackTrace><br>                    <fieldName>exTrace</fieldName><br>                    <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter"><br>                        <maxDepthPerThrowable>${maxDepthPerThrowable:-10}</maxDepthPerThrowable><br>                        <rootCauseFirst>${rootCauseFirst:-false}</rootCauseFirst><br>                        <maxLength>${maxLength:-10240}</maxLength><br>                    </throwableConverter><br>                </stackTrace><br><br>And in each service's logback.xml, adding this line just before the include of "baselogback.xml":<br><br>  <property file="....logback-custom.properties"/><br><br>Where the contents of this file might be:<br><br>    maxDepthPerThrowable    = 200<br>    rootCauseFirst          = false<br>    maxLength               = 10240<br><br>The ":-" markers in "baselogback.xml" set the defaults, so if a service doesn't make any change, they will still get the defaults.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 9, 2023 at 10:18 AM logback users list via logback-user <<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Can  you provide a super simplified example of what you wish to<br>
accomplish? In your example please use ConsoleAppender.<br>
<br>
By the way, which version of logback are you using?<br>
<br>
Here is a start:<br>
<br>
<configuration><br>
<br>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"><br>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"><br>
      <pattern>%-4relative [%thread] %-5level %logger{35} -%kvp- %msg<br>
%n</pattern><br>
    </encoder><br>
  </appender><br>
<br>
  <root level="DEBUG"><br>
    <appender-ref ref="STDOUT" /><br>
  </root><br>
</configuration><br>
<br>
<br>
On 6/9/2023 7:09 PM, logback users list via logback-user wrote:<br>
> Because, for instance, I can add a "property" element to the<br>
> "baselogback.xml" to define the property and its value, but then it<br>
> appears that any attempt to override that value from the "logback.xml"<br>
> in the service is ignored.<br>
> <br>
> On Fri, Jun 9, 2023 at 8:13 AM logback users list via logback-user<br>
> <<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a> <mailto:<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a>>> wrote:<br>
> <br>
>     I've managed to verify a setup where my "stacktrace" element in the<br>
>     "baselogback.xml" references properties, and my "logback.xml" in a<br>
>     service first specifies a properties file before including<br>
>     "baselogback.xml". That lets me control the properties in that<br>
>     element in the "baselogback.xml" from properties in the service.<br>
> <br>
>     Now I'm looking at the situation where if the "baselogback.xml" is<br>
>     changed in this way, but the service's "logback.xml" is NOT changed,<br>
>     then those properties don't have values, which doesn't cause a<br>
>     failure, it just appears to set them to their default values.  Is<br>
>     there some way, in the "baselogback.xml", I can set the default<br>
>     values for those properties, so that if the service's logback.xml<br>
>     doesn't set them, they will use the defaults instead?<br>
> <br>
>     On Thu, Jun 8, 2023 at 11:14 AM logback users list via logback-user<br>
>     <<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a> <mailto:<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a>>> wrote:<br>
> <br>
>         Hello David,<br>
> <br>
>         Variables defined in logback.xml, or as system properties or as<br>
>         environment variables are intended for substitution functionality<br>
>         elsewhere in the logback config file. I suggest that you try simpler<br>
>         examples to convince you of this.<br>
> <br>
>         It may be possible that the stackTrace element of<br>
>         LoggingEventCompositeJsonEncoder does not perform variable look up.<br>
>         However, this is an omission on the part of that component.<br>
> <br>
>         HTH,<br>
> <br>
>         -- <br>
>         Ceki Gülcü<br>
> <br>
>         Sponsoring SLF4J/logback/reload4j at<br>
>         <a href="https://github.com/sponsors/qos-ch" rel="noreferrer" target="_blank">https://github.com/sponsors/qos-ch</a><br>
>         <<a href="https://github.com/sponsors/qos-ch" rel="noreferrer" target="_blank">https://github.com/sponsors/qos-ch</a>><br>
> <br>
>         On 6/8/2023 7:49 PM, logback users list via logback-user wrote:<br>
>         > I posted this question to<br>
>         ><br>
>         StackOverflow: <a href="https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file</a> <<a href="https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file</a>> <<a href="https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file</a> <<a href="https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/76427762/can-i-override-portions-of-an-appender-defined-in-a-logback-include-file</a>>> .<br>
>         ><br>
>         > And I had posted a similar question several months ago. I<br>
>         didn't get a<br>
>         > response to the original query, and I have a feeling I won't<br>
>         get one on<br>
>         > the new query.<br>
>         ><br>
>         > Basically, I have a few hundred services that have a<br>
>         "logback.xml" file<br>
>         > that includes a "baselogback.xml" file that is defined in a common<br>
>         > place.  That "baselogback.xml" defines an appender and an<br>
>         encoder in<br>
>         > that appender, and inside that encoder, it defines a "stackTrace"<br>
>         > element that constrains the size of the stacktrace in logs.<br>
>         ><br>
>         > I'm trying to determine reasonable options for overriding<br>
>         those settings<br>
>         > in the "logback.xml" of the service itself. I'd prefer options<br>
>         that<br>
>         > don't require me to simply copy the entire appender definition<br>
>         from the<br>
>         > base and paste it into the service's logback.xml and then<br>
>         modify it.  At<br>
>         > this point, there are only specific settings I want to override.<br>
>         ><br>
>         > Another not ideal option is providing multiple<br>
>         "baselogback.xml" files<br>
>         > in the same common location (with slightly different names,<br>
>         obviously)<br>
>         > which represent commonly requested variations, like<br>
>         > "baselogback.fullstacktrace.xml", and have the service's<br>
>         logback.xml<br>
>         > include that one instead.  That still requires copying code<br>
>         and having<br>
>         > to maintain two copies, but at least it's still in a common<br>
>         place, and<br>
>         > not littered in all the services.<br>
>         ><br>
>         > Any other reasonable ideas that can make this flexible without<br>
>         a lot of<br>
>         > duplications?<br>
>         ><br>
>         ______________________________<br>
<br>
-- <br>
Support Team<br>
<a href="http://QOS.CH" rel="noreferrer" target="_blank">QOS.CH</a> Sarl (Switzerland)<br>
_______________________________________________<br>
logback-user mailing list<br>
<a href="mailto:logback-user@qos.ch" target="_blank">logback-user@qos.ch</a><br>
<a href="https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-user" rel="noreferrer" target="_blank">https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-user</a></blockquote></div>
</blockquote></div>