<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>