2

I am using pax-logging-logback and logstash-logback-encoder to log on json format to logstash. Now i want add additional fields to the JSON output by using Markers from logstash-logback-encoder.

<?xml version="1.0" encoding="UTF-8"?>

<appender name="st"
    class="net.logstash.logback.appender.LogstashTcpSocketAppender">
    <destination>127.0.0.1:6000</destination>

    <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
        <providers>

            <context/>                                
            <version/> 
            <logLevel/>
            <loggerName/>
            <message/>
            <logstashMarkers/> 

            <stackTrace/>
        </providers>
    </encoder>
</appender>

<root level="INFO">
    <appender-ref ref="st" />
</root>

logger.info(Markers.append("msg","msg"),"MSG!");

LogstashTcpSocketAppender send json to logstash but without additional fields ("msg":"msg"). When i try use the same code with simple maven project LogstashTcpSocketAppender add fields to the json.

service mix does not display any errors when the method`

logger.info(Markers.append("msg","msg"),"MSG!");

is executable.

рüффп
  • 5,172
  • 34
  • 67
  • 113
mForest
  • 88
  • 11
  • Hi @mForest, did you find any solution for his problem? Our anything you could share to help? – Lucas Pires Sep 17 '20 at 19:08
  • 1
    Hi @LucasPires, I could not find any solution that time so i used MDC e.g. MDC.put("request_id", "1"); log.info("Test Log4j with MDC"); MDC.remove("request_id"); That was 3 years ago, but as far as I can remember it added an extra field to json. – mForest Sep 18 '20 at 20:27
  • 1
    also i remember that problem was related to logback dependencies. logstash-logback-encoder depends on logback, unfortunety servismix used the wrong version of logback. – mForest Sep 18 '20 at 20:38
  • Thank you very much @mForest for replying. – Lucas Pires Sep 18 '20 at 20:46

0 Answers0