[undertow-dev] Better logging for predicates

Brad Wood bdw429s at gmail.com
Wed Jun 24 01:11:01 EDT 2020


Thanks for the reply Stuart.  I took some time and dug into this today.  I
ended up toying with a new logger class called io.undertow.predicate to be
able to isolate the predicate and handler log messages from the other stuff
already in the request logger.

>From what I see, this will work.  In order to create useful textual
representations, I'll need to override toString() in all the subclasses of

   - predicate
   - handler
   - exchangeAttribute

This is a little tedious, but doable.  The nice thing about using
toString() is I don't need to add any methods to the interfaces and it has
a somewhat-useful fallback of just showing the class name of the
predicate/handler.

What I've been playing with is adding a single debug message to each
handler when it fires that describes what action it has taken on the
request.  And then adding a series of trace messages to the
PredicatesHandler that shows every predicate that was tested as well as
other flow control actions like the pseudo "restart" and "done" handlers.
Additionally, trace messages can be added to specific predicates as
necessary to show the runtime values used to resolve them.

Are there any considerations you'd like me to take into account?  For
example, I see other usages of logging check to see if debug/trace is
enabled prior to making the logging calls so I assume you'll want to stick
with that pattern.  My initial work is here in this branch of my fork:
https://github.com/Ortus-Solutions/undertow/commits/predicate-logging

Thanks!

~Brad

*Developer Advocate*
*Ortus Solutions, Corp *

E-mail: brad at coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com



On Tue, Jun 23, 2020 at 11:02 PM Stuart Douglas <sdouglas at redhat.com> wrote:

> This sounds like a good idea to me.
>
> Stuart
>
> On Wed, 24 Jun 2020 at 05:53, Brad Wood <bdw429s at gmail.com> wrote:
>
>> I've been using Tuckey Rewrites for a long time and one of my favorite
>> things about it is the very rich amount of debug and trace logging
>> information it has.  There's not another rewrite engine out there I've seen
>> that makes it this easy to debug what's happening.  The trace level logging
>> gives you a full blow-by-blow of each rule that's processed, what the input
>> was, and what the result of each condition was.
>>
>> As much as I love Undertow's predicates and handlers, the logging is,
>> well, abysmal :)  I'd like to do some work to improve what gets sent to the
>> request_logger for debugging the predicates and handlers that fire for a
>> request as part of the PredicatesHandler.  My high-level approach is as
>> follows:
>>
>>    - Override the toString() method in each of the built-in predicates
>>    and handlers to create a basic text representation of them that isn't too
>>    far from the predicate language.
>>    - Add logging at key points in the PredicatesHandler that captures
>>    each predicate as it is evaluated as well as the result of that predicate
>>    and the next handler to be invoked.
>>    - I'd probably say a single debug log entry for every matched
>>    predicate for basic high-level debugging of predicates that had some sort
>>    of effect on the request.
>>    - And then a trace log entry with all the juicy details of each
>>    predicate whether it was matched or not for debugging why predicates aren't
>>    working correctly
>>
>> So again, I'm offering to work on this and contribute it to Undertow as a
>> pull, but I'd like some feedback on my idea and a general sanity check on
>> whether I'm wasting my time here.  Well, honestly, I'll probably do the
>> work regardless because the user's of my Undertow-powered tool will need
>> it, but I'd like to know if these improvements would be welcomed into the
>> core.
>>
>> Thanks!
>>
>> ~Brad
>>
>> *Developer Advocate*
>> *Ortus Solutions, Corp *
>>
>> E-mail: brad at coldbox.org
>> ColdBox Platform: http://www.coldbox.org
>> Blog: http://www.codersrevolution.com
>>
>> _______________________________________________
>> undertow-dev mailing list
>> undertow-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20200624/c496cae1/attachment.html 


More information about the undertow-dev mailing list