-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
LOGBACK-1052 Have RequestLogImpl implement Jetty's LifeCycle interface #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Have RequestLogImpl implement Jetty's LifeCycle interface directly. This allows logback access to work with Jetty 9.3.0M1 and newer, where the Jetty API was changed in an incompatible way.
|
Have |
|
+1 - Jetty 9.3 is released now and this needs to be fixed :) |
|
+1 to get this fixed, logback-access is useless asis in Jetty 9.3+ w/o this change. BTW I tested locally on master and I only had to add Jetty LifeCycle to the impl, no other changes: |
|
Any update on this? |
|
FWIW, you can workaround this issue by extending the base class and adding the missing interface as a stopgap if you don't want to rebuild everything from source. package com.example.ch.qos.logback.access.jetty;
import ch.qos.logback.access.jetty.RequestLogImpl;
import org.eclipse.jetty.util.component.LifeCycle;
public class RequestLogImpl_Fix_LOGBACK_1052 extends RequestLogImpl implements LifeCycle {
}The Jetty config would just need to be updated to use the wrapper class. <Ref id="RequestLogHandler">
<Set name="requestLog">
<New id="requestLogImpl" class="com.example.ch.qos.logback.access.jetty.RequestLogImpl_Fix_LOGBACK_1052"/>
</Set>
</Ref> |
|
If the fix doesn't seem imminent, I'd like to suggest the docs be updated to reflect this situation. I spent an unfortunate amount of time trying to work out why it's not working properly and would like to save others the pain. |
|
@kylesm Do you happen to know if this fix will be backwards compatible with older versions of Jetty? Just curious if this interface was introduced in the 9.x line. |
|
@robmoore the LifeCycle interface has been around since at least Jetty 6.1.2. A couple of methods were added to it in Jetty 7 but RequestLogImpl has stubbed out versions of them (add/removeLifeCycleListener), so it shouldn't alter the minimum supported version of Jetty. |
|
@kylesm Thanks, Kyle. I was thinking that perhaps the issue of backwards compatibility was what might be holding this fix up. Good to know it's not an issue. |
|
The This was done to address many a bug with async request logging, along with request logging of bad requests (ones that cannot be sent to a context). Since you are using slf4j & logback, you no longer need logback-access in Jetty 9.3+ Use the |
|
@joakime That does work, but logback-access has specific access log PatternLayout that is really useful in order to create the log format. I cant see how to create a similar access log format using the pattern facilities in Logback itself without having to write a load of code. Do you know of a way? |
|
@ChrisMacpherson-awin seeings as the Jetty Altering it with a customizable pattern would no longer make it NCSA format compatible. This logback-access pull request has it now using a LifeCycle, which is fine. |
|
@joakime Okay maybe I just didn't understand the hook up correctly. In logback it needs an encoder in the appender that you use in the named logger. I couldn't work out how to configure it to output the request log data directly without using a pattern. Do you know of any examples anywhere. I couldn't find any. Anyway I've probably digressed from the purpose of this pull request |
|
Is there an update on why this PR couldn't be incorporated? We wasted many hours tracking down this issue for what looks like a simple fix that could have been implemented years ago. The current documentation for Jetty 9.3+ and Logback doesn't indicate that We also are using logback custom layouts so switching to |
|
Bump? Any updates? |
|
we also using @tpounds workaround - rebase/merge this PR please ! |
|
What wrong with this PR (I mean why it isn't accepted)? I'm one of those folks that spent several hours of debugging to understand why the documented behaviour of This PR is almost 4 years old and all this time people like me spend time for no reason. If several years ago Jetty 9.3 can be seen as something new, now it is very actual version, if not old (I use 9.4.7 and current version is 9.4.15). So with time passing this PR's demand will only increase. |
|
Note that Jetty 9.4.15+ has a CustomRequestLog that accepts formatting. Example usage (with slf4j) Slf4jRequestLogWriter slf4jRequestLogWriter = new Slf4jRequestLogWriter();
slf4jRequestLogWriter.setLoggerName("my.requestlog"); // the slf4j named logger to output to
// The format of the output. (See javadoc for CustomRequestLog for details)
String requestLogFormat = "%{client}a - %u %t \"%r\" %s %O \"%{Referer}i\" \"%{User-Agent}i\"";
CustomRequestLog requestLog = new CustomRequestLog(slf4jRequestLogWriter, requestLogFormat);
server.setRequestLog(requestLog); |
|
Thanks @joakime ! But unfortunately, it doesn't have parity in functionality with For example, what I need:
The main difference between |
This probably doesn't work on HTTP/2 (or the upcoming HTTP/3), nor would presenting the header hierarchy (current exchange's http fields delta to physical connection's http fields) be useful.
Any request buffering solution, using traditional Servlet 2.x techniques is incompatible with Servlet 3.0 and the various Async I/O processing.
This is supported by ContextHandler facilities in Jetty already. Finally ... If these features are what you want, then using Jetty's Lets evaluate ... Regarding Regarding the Regarding Full Request / Response body ... Regarding the filtering by URL ... |
`LogbackAccessRequestLog` is registered as a bean, but doesn't implement `LifeCycle` (see qos-ch/logback#269). If we manually implement `LifeCycle`, which the `RequestLogImpl` actually does with its methods, the component is registered as a managed object rather than a POJO and therefore is started and stopped by the Jetty server. Closes #3226
Have RequestLogImpl implement Jetty's LifeCycle interface directly. This
allows logback access to work with Jetty 9.3.0M1 and newer, where the
Jetty API was changed in an incompatible way.