eclipse-ee4j / jersey

Eclipse Jersey Project - Read our Wiki:
https://github.com/eclipse-ee4j/jersey/wiki
Other
691 stars 353 forks source link

difficult to reliably enable access logging w/ Grizzly #2966

Open jerseyrobot opened 9 years ago

jerseyrobot commented 9 years ago

Ran into a couple of issues w/ GrizzlyHttpServerFactory today.

1. Most of the methods auto-start the Grizzly instance.

2. Grizzly silently accepts requests to configure access logs after it's already running, but doesn't pass the configuration into the Grizzly backend threads so the logging silently fails.

3. There is a public method on GrizzlyHttpServerFactory which is uncallable by anybody. It requires a GrizzlyHttpContainer but you aren't allowed to create one yourself (I don't think there's a good reasony you aren't allowed to create one but nevertheless.

public static HttpServer createHttpServer(final URI uri,
              final GrizzlyHttpContainer handler,
              final boolean secure,
              final SSLEngineConfigurator sslEngineConfigurator,
              final boolean start)
public HttpServer getHttpServer() {
        ...
        HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false, null, false);
        enableAccessLog(httpServer);
        try {
            httpServer.start();
        }
        catch (Exception e) {
            log.error("could not start Grizzly server", e);
            throw new RuntimeException(e);
        }

        return httpServer;
    }

    public static void enableAccessLog(HttpServer httpServer) {
        AccessLogAppender appender = new StreamAppender(System.out);
        AccessLogFormat format = ApacheLogFormat.COMBINED;
        int statusThreshold = AccessLogProbe.DEFAULT_STATUS_THRESHOLD;
        AccessLogProbe alp = new AccessLogProbe(appender, format, statusThreshold);
        ServerConfiguration sc = httpServer.getServerConfiguration();
        sc.getMonitoringConfig().getWebServerConfig().addProbes(alp);
    }

Environment

Using Grizzly Web Server, Any Platform

Affected Versions

[2.13]

jerseyrobot commented 6 years ago
jerseyrobot commented 9 years ago

@glassfishrobot Commented Reported by mhcptg

jerseyrobot commented 9 years ago

@glassfishrobot Commented @AdamLindenthal said: Hi mhcptg,

thanks for describing your problem. I am moving it to our backlog, so that we can plan to look at this at some later point.

Regards, Adam

jerseyrobot commented 9 years ago

@glassfishrobot Commented @mpotociar said: Reclassifying as improvement.

jerseyrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-2694