eclipse-ee4j / eclipse-ee4j/jersey
difficult to reliably enable access logging w/ Grizzly
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
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]
Contributor guide
Assessment
This issue has not been assessed yet.