• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Spring Boot session logging  RSS feed

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

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?

Cheers
 
Sheriff
Posts: 21719
102
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.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!