log-helper
configures console log to include additional fields for traceability purposes.
spring.application.name
, make sure to configure it in bootstrap.properties.traceId
andspanId
from Spring Cloud Sleuth.- Extra field from HTTP header. By default, it propagates
correlationId
.
Note:
log-helper
uses Log4j2.
- Add dependency to
pom.xml
.<dependency> <groupId>com.example</groupId> <artifactId>log-helper</artifactId> <version>X.Y.Z-SNAPSHOT</version> </dependency>
- Configure
spring.application.name
in bootstrap.properties. - Perform logging using
@Log4j2
. Sample output as below.spring.application.name=demodemo
traceId
is f7b518334ee1d87cspanId
is h8r3hqaiofhaw8oscorrelationId
is 3
2019-04-20 14:52:39.258 INFO [demodemo,f7b518334ee1d87c,h8r3hqaiofhaw8os,3] 50823 --- [nio-8080-exec-1] c.e.MyController : logging with Log4j2 - hello! 3