Skip to content

Demo for enable global param via spring boot and trace via log

Notifications You must be signed in to change notification settings

ADU-21/global-param-trace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Global param trace demo

This is a demo for enable global param via spring boot and trace via log.

Blog: https://www.duyidong.com/2019/12/21/spring-boot-log-trace/

How to use

  • Start server
mvn clean install    # Install dependencey
mvn spring-boot:run  # Start application 
  • Test api
curl -H 'User-Id:1' -H 'Trace-Id:123' localhost:8080/user   # Should response user info
curl -H 'User-Id:4' -H 'Trace-Id:123' localhost:8080/user   # Should response error
curl -X POST -H 'User-Id:1' -H 'Trace-Id:123' -H 'Content-Type: application/json' -d '{"name":"John"}' localhost:8080/user # add new user, should response 4
curl -X POST -H 'User-Id:1' -H 'Trace-Id:123' -H 'Content-Type: application/json' -d '{"name":"John"}' localhost:8080/user # add new user, should response permission deney
curl -H 'User-Id:4' -H 'Trace-Id:123' localhost:8080/user   # Should response user with name John after add user success
  • Check log file
tail -f ~/global-param-trace/logs/application.log

About

Demo for enable global param via spring boot and trace via log

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages