-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jetty logging supporting Throwable as last argument #4567
Comments
@joakime perhaps we can review the API and completely drop those that have an explicit |
Some other logging APIs. (they actually use |
Yes, but there is no need to if you probe the last argument. One API only ( |
If we are changing logging, should we switch to String.format style rather than {} style? |
The |
If we are entertaining the cleanup of the logging API, how about we just drop all of Jetty logging and use I think this is a good direction to go, and should also have a positive impact (simplifying) on our jetty-home logging modules. |
@joakime good idea! worth to try but no more LOG.ignore? |
ProposalDrop org.eclipse.jetty.util.logThe entire package Create jetty-slf4j-impl moduleA new module called This module performs the equivalent to Jetty's StdErrLog.
It has a A package space of org.eclipse.jetty.logging This new module would be included as a Migrate logging propertiesExisting properties
Dropped properties
Renamed properties
Migrate source to use slf4jMigrate code from ... import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
private static final Logger LOG = Log.getLogger(DoSFilter.class); ... to ... import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(DoSFilter.class); The usage of LOG.trace("IGNORED", cause); The New logging modules for jetty-homeThe existing logging modules in Jetty 9.4.x are ...
We would simplify this a great deal to just ...
Where each logging module captures all logging implementations The new modules would also no longer force a forking of a JVM. |
Any special configuration challenges to capturing and directing webapp logging? |
Had a look at But no, they lack features like MDC and the APIs require to pass a I think the big overhaul of the logging would be a good change, but for Jetty 12. For Jetty 10, probing just the last parameter should be simple and small enough. |
It would just be a configuration of the |
Checkstyle fixes ... + Log.__loggers now Log.LOGGERS + Log.__props now Log.PROPS + StdErrLog.__tagpad now StdErrLog.THREADNAME_PADDING + StdErrLog.__source now StdErrLog.SOURCE + StdErrLog.__long now StdErrLog.LONG_CLASSNAMES + StdErrLog.__escape now StdErrLog.ESCAPE_CONTROL_CHARS + Removed redundant "public" modifier on Log interface methods New code ... + New Log.getProperty(String key, String defaultValue) Used by JavaUtilLog, JettyLogHandler, and StdErrLog + New StdErrLog.getConfiguredLevel() + New StrErrLog.println(String) used to write StringBuilder to configured PrintStream Removed code ... + Removed deprecated prop check in StdErrLog initialization Cleanup and Corrected code ... + StdErrLog.setDebugEnabled(boolean) cleanup + StdErrLog._stderr is now used and is never null + Only one StdErrLog.format() method entry point + StdErrLog.format(StringBuilder, Throwable) now called .formatCause(StringBuilder, Throwable, String) Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
I like the proposed change to direct use of log4j, but I don't think we can go directly there without deprecating the existing mechanism. However, I do think within 10/11 we can change to using log4j directly and deprecate the old API, then 12 we can remove the old API. Means we still have some module complexity for a while.. at least in the naming, but the contents should become simpler. If we do it this way, no need to hold up 10.0.0 for this to be implemented. So let's just go with sniffing the last param for now. |
log4j1 is not very performant and is abandoned now. Opened PR #4570 for the last argument sniffing for Throwable. The time needed to make the change in the Proposal is only about 2 days. |
Opened Issue #4572 to track the larger Proposal separately |
ooops did I say log4j, I meant slf4j! slf4j is just a facade like our own Logging API, so it essentially gives us the same flexibility, but with less complexity at the small cost of an API jar dependency. |
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…ng "null") Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…owable Issue #4567 - StdErrLog cleanup and final Arg Throwable support
Reopening for Jetty 9.4.x too |
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…lastarg Issue #4567 - Backport of StdErrLog 10.0.x for Throwable behavior change
PR #3596 merged. |
Jetty version
10.0.x
Description
Like other logging frameworks, would be handy if Jetty logging (
StdErrLog
) could detect whether the last argument is aThrowable
and if so print its stack trace.In this way one could write:
rather than:
The text was updated successfully, but these errors were encountered: