Felix
Felix

Reputation: 4595

How to configure WildFly 8.2 to use AccessLogHandler

I have found that there is a handler io.undertow.server.handlers.accesslog.AccessLogHandler that can log http access.

However I am not able to configure it so it will produce any log messages.

Here is a code snippet from my standalone.xml:

<filter class-name="io.undertow.server.handlers.accesslog.AccessLogHandler" name="access-log-handler" module="io.undertow.core">
    <param name="formatString" value="common"/>
    <param name="accessLogReceiver" value="io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver"/>
</filter>

My question is how to configure that handler so it will start producing log messages.

Upvotes: 1

Views: 3631

Answers (2)

Tomaz Cerar
Tomaz Cerar

Reputation: 5791

no need to add custom filter for access log. All you need is to configure access log in subsystem itself. This would be an example:

<host name="default-host" >
    <location name="/" handler="welcome-content">
     ....    
    <access-log />
</host>

which will by default log in to log folder with prefix access_.log

you can also customize various things, from xsd:

<xs:attribute name="pattern" use="optional" type="xs:string" default="common"/>
<xs:attribute name="worker" use="optional" type="xs:string" default="default"/>
<xs:attribute name="directory" use="optional" type="xs:string" default="${jboss.server.log.dir}"/>
<xs:attribute name="relative-to" use="optional" type="xs:string" />
<xs:attribute name="prefix" use="optional" type="xs:string" default="access_log"/>
<xs:attribute name="suffix" use="optional" type="xs:string" default=".log"/>

Upvotes: 4

Felix
Felix

Reputation: 4595

I missed to add this xml snippet (StackOverflow):

<host name="default-host" >
     .....
     <filter-ref name="access-log-handler"/>
</host>

And then I got this:

Caused by: java.lang.NoSuchMethodException: io.undertow.server.handlers.accesslog.AccessLogHandler.<init>(io.undertow.server.HttpHandler)"}}

Which is a known bug: see this, or this

It is possible to use jboss-cli to add a handler and see how the standalone.xml changed:

/subsystem=undertow/configuration=filter/custom-filter=access-log-handler:add(class-name=io.undertow.server.handlers.accesslog.AccessLogHandler, module=io.undertow.core)
/subsystem=undertow/server=default-server/host=default-host/filter-ref=access-log-handler:add

Upvotes: 0

Related Questions