..." /> ..." /> ..."/>

how to strip a variable using logback after a delimiter

14 Views Asked by At

I am utilizing Logback for some logging and my current logback-spring.xml file contains the following lines:

<property resource="git.properties"/>

...

<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashAccessTcpSocketAppender">
    <destination>localhost:5000</destination>
    <encoder class="net.logstash.logback.encoder.LogstashEncoder">
        <customFields>{ "branch":"${git.branch}"</customFields>
    </encoder>
</appender>

Now in my output, I properly get the name of my git branch. But my branches utilize the following naming convention <issue#>-description-more-details. So if I'm working on Issue #747 Fix logging, my branch name would be 747-fix-logging.

What I would like to do is add additional output that simply outputs the Issue number. so my log would look like the following:

[yyyy-mm-dd] INFO --- 747-fix-logging
[yyyy-mm-dd] INFO --- 747

I know it's stupid but I've learned just not to ask questions. Any help would be great.

0

There are 0 best solutions below