Jersey 如何在grizzly服务器控制台上获取HTTP请求日志?

Jersey 如何在grizzly服务器控制台上获取HTTP请求日志?,jersey,jax-rs,grizzly,Jersey,Jax Rs,Grizzly,在Jersey的用户指南教程之后,我创建了一个基于jax-rs的小型RESTWeb应用程序。这是启动服务器的主类 public class Main { // Base URI the Grizzly HTTP server will listen on public static final String BASE_URI = "http://localhost:8080/myapp/"; /** * Starts Grizzly HTTP server exposing JAX-RS r

在Jersey的用户指南教程之后,我创建了一个基于jax-rs的小型RESTWeb应用程序。这是启动服务器的主类

public class Main {
// Base URI the Grizzly HTTP server will listen on
public static final String BASE_URI = "http://localhost:8080/myapp/";

/**
 * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
 *
 * @return Grizzly HTTP server.
 */
public static HttpServer startServer() {
    // create a resource config that scans for JAX-RS resources and providers
    // in com.example package
    final ResourceConfig rc = new ResourceConfig().packages("com.example");

    // create and start a new instance of grizzly http server
    // exposing the Jersey application at BASE_URI
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}

/**
 * Main method.
 *
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    final HttpServer server = startServer();
    System.out.println(String.format("Jersey app started with WADL available at "
            + "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
    System.in.read();
    server.shutdownNow();
   }
}
GET请求的资源方法处理程序:

@Path("myresource")
public class MyResource {

/**
 * Method handling HTTP GET requests. The returned object will be sent
 * to the client as "text/plain" media type.
 *
 * @return String that will be returned as a text/plain response.
 */
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
    return "Got it!";
   }
}
当我运行服务器时,我会在控制台上看到:

"C:\Program Files\Java\jdk1.8.0_171\bin\java.exe" ... 
 Sep 10, 2018 11:51:55 AM org.glassfish.grizzly.http.server.NetworkListener 
 start
 INFO: Started listener bound to [localhost:8080]
 Jersey app started with WADL available at 
 http://localhost:8080/myapp/application.wadl
 Hit enter to stop it...
 Sep 10, 2018 11:51:55 AM org.glassfish.grizzly.http.server.HttpServer start
 INFO: [HttpServer] Started.
当我通过邮递员向发送GET请求时,它会给我一个状态200 OK,并将“Got it!”作为响应主体,但服务器控制台中不会记录任何内容


这可能是一个非常基本的问题,但如何实现它,以便每次向grizzly服务器发送HTTP请求时,请求和响应都会记录在控制台上?我真的很感激任何帮助

很抱歉,您已经找到解决方案了吗?