springboot mvc + slf4j and log4j2 + request trace configuration
Demonstrates how we can use log4j2 filters to change logging level and redirect logs to the different (tracking log) file. You can track a request using a tag specified in the request.
To enable fishing you need to set the following HTTP headers:
- fishing-level - obligatory, fishing logging level ['debug','trace']
- fishing-tag - optional, custom tag which will be set in logging ThreadContext and used in logging pattern
curl --header "fishing-level: debug" localhost:8080/fishing
fishing on debug level with autogenerated tag '
curl --header "fishing-level: trace" --header "fishing-tag: my-fishing-tag" localhost:8080/fishing
fishing on trace level with custom tag
Fishing logs will be forwarded to log4jfishing.trace.log for custom setting please reffer to https://logging.apache.org/log4j/2.0/manual/configuration.html and project log4j2.xml file.