Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Spring Boot session logging  RSS feed

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm after some best practice / advice.

I have a Spring Boot servlet web service which is called with some HTTP header information.  I need to output this header information in any trace files which are produced by the application.  Tracing is done my log4j2, and I'm after advice as to how to ensure that this header information is available to all classes within the application so it can be included in the logs.

I thought about placing the information into session, and then make this httpSession object available thoughout the application but this seems like overkill.  Are there any other recommended ways to do this?

Posts: 21747
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you only need to include it in your logs, you should probably put it in your thread context (MDC in Log4J 1, SLF4J and Logback), then change your log pattern layout to include these values.
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!