I recently changed our application from log4j to logback / slf4j. Everything works very well, however I want to implement something specific.
The application I'm working on is a web application. In our production environment, the log level is at INFO. From time to time, tickets are sent to our service team. It would be nice that when our service team plays tickets, they can put the log level on TRACE only for their test request. Thus, the log files will not vote for all other requests included at this time.
We already use the header "X-TracingContext-Active = true" to write some additional data to the log. My idea was to extend loglevel to TRACE when the title is "true" for this request (stream) only.
Is there a way to do this without having to create my own logging implementation or write this logic in each class?
EDIT: The X-TracingActive-Context header is now fixed at the beginning of each request. This value is stored in a helper class in the ThreadLocal variable. I was thinking of overriding the methods isInfoEnabled, isDebugEnabled, ... so it first reads the variable from the helper class. But I have no idea how I can override this method without implementing my own log structure. The Logger class is final.
Any ideas?
source
share