Currently, JettyWebServerFactoryCustomizer
always creates a RequestLogWriter
in case accesslog is enabled in the Server properties.
The format of the log message can be customized already, but not the writer type.
It would be good to have additional properties such as logger type and logger name which could be configured to create a org.eclipse.jetty.server.Slf4jRequestLogWriter
instead.
Comment From: philwebb
I wonder a logger-name
property alone would be enough of a signal that you want SLF4J logging. If you want to use the standard output you'd need server.jetty.accesslog.logger-name=org.eclipse.jetty.server.RequestLog
.
If we did add this, we should probably also fail hard if any of the file
properties are set.
Comment From: philwebb
We discussed this today on our team call and feel a customizer is currently the better option if you want SLF4J logging.
Whilst a property source be nice, we'd really want to move the existing file based properties under a different key so that there's less confusion about when they apply. We'd also ideally also want a way to configure Tomcat and Undertow in the same way.
JettyWebServerFactoryCustomizer always creates a RequestLogWriter
This isn't actually the case. The customizeAccessLog
method is only called if server.jetty.accesslog.enabled
is true
. That means, the following code should be all that's needed if you want to pick a different logging implementation:
@Bean
JettyServerCustomizer customLogFormat() {
return (server) -> server.setRequestLog(
new CustomRequestLog(new Slf4jRequestLogWriter(), CustomRequestLog.NCSA_FORMAT));
}