WildFly users

WildFly uses Undertow as Web server, which has deprecated the element Valve used in former Tomcat Web Server. You can still monitor HTTP logging by adding a Filter to your configuration as in this example:

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

 You can add the Filter to your configuration using the following CLI command:

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

The RequestDumpingHandler filter will produce a verbose output, therefore it's recommended not to use it in production to avoid performance issues.

On the other hand, if you just want to keep track of the access-log of your server then you have to enable the access-log setting of your Host as follows:

/subsystem=undertow/server=default-server/host=default-host/setting=access-log:\
add(pattern="%h %t \"%r\" %s \"%{i,User-Agent}\"", use-server-log=false)

 This reflects in the following configuration:

<host name="default-host" alias="localhost">
      <location name="/" handler="welcome-content"/>
      <access-log pattern="%h %t &quot;%r&quot; %s &quot;%{i,User-Agent}&quot;" use-server-log="false"/>
       <http-invoker security-realm="ApplicationRealm"/>
</host>

 As you can see, we have set the property "use-server-log" to false so that Undertow writes logs in a separate file named access_log.log, in the configuration/log folder:

~/jboss/wildfly-15.0.0.Final/standalone/log: ls -al
-rw-rw-r--. 1 wildfly wildfly  62997 Jan 17 10:39 access_log.log
-rw-rw-r--. 1 wildfly wildfly      0 Dec 17 15:59 audit.log
-rw-rw-r--. 1 wildfly wildfly 589363 Jan 17 10:38 server.log

 If set to "true", then the logs will be merged into the server.log file:

2019-01-17 10:37:22,968 INFO  [io.undertow.accesslog] (default task-16) 127.0.0.1 [17/Jan/2019:10:37:22 +0100] "GET /api/v1/services?resourceVersion=0 HTTP/1.1" 404 "kube-proxy/v1.4.5 (linux/amd64) kubernetes/5a0a696"
2019-01-17 10:37:22,974 INFO  [io.undertow.accesslog] (default task-16) 127.0.0.1 [17/Jan/2019:10:37:22 +0100] "GET /api/v1/services?resourceVersion=0 HTTP/1.1" 404 "kubelet/v1.4.5 (linux/amd64) kubernetes/5a0a696"
2019-01-17 10:37:22,974 INFO  [io.undertow.accesslog] (default task-15) 127.0.0.1 [17/Jan/2019:10:37:22 +0100] "GET /api/v1/nodes?fieldSelector=metadata.name%3D127.0.0.1&resourceVersion=0 HTTP/1.1" 404 "kubelet/v1.4.5 (linux/amd64) kubernetes/5a0a696"
2019-01-17 10:37:23,095 INFO  [io.undertow.accesslog] (default I/O-3) 127.0.0.1 [17/Jan/2019:10:37:23 +0100] "PATCH /api/v1/namespaces/default/events/127.0.0.1.1578746cbfbd144d HTTP/1.1" 501 "kubelet/v1.4.5 (linux/amd64) kubernetes/5a0a696"
2019-01-17 10:37:23,293 INFO  [io.undertow.accesslog] (default I/O-3) 127.0.0.1 [17/Jan/2019:10:37:23 +0100] "PATCH /api/v1/namespaces/default/events/127.0.0.1.1578746cbfbcdc31 HTTP/1.1" 501 "kubelet/v1.4.5 (linux/amd64) kubernetes/5a0a696"

 JBoss AS 7 / JBoss EAP 6 users

To enable HTTP logging, you need to go to the deploy/jbossweb-tomcat55.sar directory. There you will see the server.xml file, to which you'll need to add the following valve definition:

<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
           prefix="localhost_access_log." suffix=".log"
           pattern="common" directory="${jboss.server.home.dir}/log"
           resolveHosts="false" />

A Valve element represents a component that will be inserted into the request processing pipeline for the associated Catalina container. The Access Log Valve creates log files in the same format as those created by standard web servers. These logs can later be analyzed by standard log analysis tools to track page hit counts, user session activity, and so on. The files produces by this Valve are rolled over nightly at midnight.

Once you've restarted the server, Tomcat will create an access log.

0
0
0
s2smodern

Related articles available on mastertheboss.com

How do I reload dynamically my jsp from an ear ?

  Deploy your Jsp as part of an application deployed in exploded

Where is my compiled JSP ?

JBoss recipe of the day

JBoss Struts tutorial

This article explains how you can setup quickly an application ba

How to restrict access to JBoss web application by IP or Host?

You can create easily Access control list based on the IP address

How do you configure a Web Application as Default Web app ?

WildFly users For WildFly users you have to include in jboss-web

Developing Portlets with JBoss Portal

JBoss Portal is an open source platform for hosting and serving a