Skip to content

Debug-log all http traffic via JAX-RS or MicroProfile REST Client; server and client side

Notifications You must be signed in to change notification settings

t1/jax-rs-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JAX-RS Logging badge badge

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 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 <hidden>; 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

<<<

About

Debug-log all http traffic via JAX-RS or MicroProfile REST Client; server and client side

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages