Search code examples
logstashlogbackmicroservicesspring-cloud-sleuth

Spring Sleuth Logback Integration logs not displaying the service name


In my microservice i have added spring -sleuth 1.2.1 and i have received the logs as i expected, which is shown in below

2017-08-16 09:58:51.864 INFO [microServiceName,9434118b965d573e,9434118b965d573e,true] 1328 --- [io-8081-exec-10] com.cibc.icap.MyController : Eligible for Vote

As per my requirement I need to pass the logs from my application to logstash server so i have created logback.xml and added dependency logstash-logback-encoder-4.5.1 and added the appender in logback.xml net.logstash.logback.appender.LogstashTcpSocketAppender my logback.xml looks like now the logs are passing from my application to logstash but the problem is in the log I am not getting my microservice name as expected, The log looks like below after adding the logback.xml

2017-08-17 12:35:27.781 INFO [bootstrap,0e26cf339a6e69bc,0e26cf339a6e69bc,true] 4884 --- [nio-8081-exec-7] com.cibc.icap.AssessmentController

link for my logback.xml


Solution

  • Add the spring.application.name to bootstrap.yaml. If that doesn't work just follow the example of logback configuration from the docs http://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html#_json_logback_with_logstash