https://github.com/t1/jax-rs-logging
Debug-log all http traffic via JAX-RS or MicroProfile REST Client; server and client side
https://github.com/t1/jax-rs-logging
jakarta-ee java-ee jax-rs jee logging microprofile-restclient
Last synced: 5 months ago
JSON representation
Debug-log all http traffic via JAX-RS or MicroProfile REST Client; server and client side
- Host: GitHub
- URL: https://github.com/t1/jax-rs-logging
- Owner: t1
- Created: 2022-03-30T06:10:02.000Z (over 3 years ago)
- Default Branch: trunk
- Last Pushed: 2024-10-21T18:54:32.000Z (12 months ago)
- Last Synced: 2024-10-22T11:17:31.938Z (12 months ago)
- Topics: jakarta-ee, java-ee, jax-rs, jee, logging, microprofile-restclient
- Language: Java
- Homepage:
- Size: 70.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= JAX-RS Logging image:https://maven-badges.herokuapp.com/maven-central/com.github.t1/jax-rs-logging/badge.svg[link=https://search.maven.org/artifact/com.github.t1/jax-rs-logging] image:https://github.com/t1/jax-rs-logging/actions/workflows/maven.yml/badge.svg[link=https://github.com/t1/jax-rs-logging/actions/workflows/maven.yml]
//image:https://maven-badges.herokuapp.com/maven-central/com.github.t1/jax-rs-logging/badge.svg[link=https://search.maven.org/artifact/com.github.t1/jax-rs-logging]
Log all http traffic coming in or going out with JAX-RS, i.e. request/status, headers and (text)body coming in and returned by a server as well as sending out and receiving back by a client.
It logs at `DEBUG` level using https://www.slf4j.org[slf4j].
It tries to find out what API class was used (or fall back to a generic logger), e.g. when you use MP REST Client, it uses the name of the client API interface as the logger.
On the server, I didn't find a standardized way to find out what API class handles the request; so that works currently only for RestEasy... any hints are very welcome.If the logger is not enabled (at `DEBUG` level), it looks for a logger config with an additional `..single` suffix, i.e. if the method is `test.Ping#ping` and `test.Ping.ping` is disabled, it looks if `test.Ping.ping..single` or `test.Ping..single` or `test..single` or `..single` or the root logger is enabled.
In this case, it logs the request and response in a single multi-line log invocation.
If that is still disabled, it logs nothing.It logs the `Authorization` header value as ``; with one exception: we consider passwords in a `Basic` auth with at least 12 characters to be safe enough, so we can log the username and only hide the password.
This often makes debugging issues with credentials easier, as it easily happens that you use the _wrong credentials_, but it's much less likely that you use the _wrong password_ for the correct user.It joins repeated headers into a single, comma separated log line.
To use it, simply add it to your runtime classpath.
Depending on the direction, different prefixes are logged:
|===
|Side |Direction |Prefix|Client |Call |`>>`
|Client |Result |`<<`|Container |Receive |`>>>`
|Container |Return |`<<<`
|===