Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Created August 2, 2022 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeltuelho/db87269b04a715f34cc51da4344563a2 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/db87269b04a715f34cc51da4344563a2 to your computer and use it in GitHub Desktop.
package org.acme.rest.json;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Provider;
import org.jboss.logging.Logger;
import io.vertx.core.http.HttpServerRequest;
@Provider
public class QuarkusLoggingFilter implements ContainerRequestFilter {
private static final Logger LOG = Logger.getLogger(LoggingFilter.class);
@Context
UriInfo info;
@Context
HttpServerRequest request;
@Override
public void filter(ContainerRequestContext context) {
final String method = context.getMethod();
final String path = info.getPath();
final String address = request.remoteAddress().toString();
LOG.infof("Request %s %s from IP %s", method, path, address);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment