Dump HTTP requests in WildFly 8

旧时模样 提交于 2019-11-27 20:07:48

You would need to add RequestDumpingHandler to your handler chain.

As part of wildfly 8.1, that is not yet possible in a friendly way.

This is improved in 8.2 and 9 so you will be able to configure this by adding something like this:

<host name="default-host" >
     .....
     <filter-ref name="request-dumper"/>
</host>
....
<filters>
    ...
    <filter name="request-dumper" class-name="io.undertow.server.handlers.RequestDumpingHandler" module="io.undertow.core" />
</filters>

in 8.1 only option now would be to add ServletExtension http://undertow.io/undertow-docs/undertow-docs-1.2.0/#servlet-extensions

that would add this RequestDumpingHandler to outer chain.

FWIW 8.2 release is almost ready, so you could wait for it or just build sources for 8.x branch.

To add above config via CLI, you can use:

/subsystem=undertow/configuration=filter/custom-filter=request-dumper:add(class-name="io.undertow.server.handlers.RequestDumpingHandler",  module="io.undertow.core")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=request-dumper:add

There are a number of people asking how to get the entire HTTP body logged out, not just the headers.

It seems an answer exists: https://8bitplatoon.blogspot.com/2017/02/dumping-http-requests-and-responses-in.html

In short, if that link doesn't survive, a simple addition to your standalone.xml will do the trick:

<system-properties> <property name="com.sun.xml.ws.transport.http.HttpAdapter.dump" value="true"/> </system-properties>

I added this after the <extensions>...</extensions> and before <management>...</management>, restarted wildfly, and was able to get complete HTTP bodies in my server logs (server.log in my case).

This does not interact with or depend on the Undertow "request dumper" at all as far as I can tell, you can do one, the other, or both.

On Wildfly 9 and 10.1.0, it works just by adding

            <subsystem xmlns="urn:jboss:domain:undertow:3.1">
            <server name="default-server">
            <host name="default-host" alias="localhost">
                <access-log/>
            </host>
            </server>
            </sub-system>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!