How to enable access logging (accesslog) in JBoss EAP 7

Configuring JBoss EAP 7 to write an access log (e.g. like Apache webserver) is quite easy with the CLI:

/subsystem=undertow/server=default-server/host=default-host/setting=access-log:add

If you need any additional configuration, take a look at this: Wildfly 10.0.0.Final Model Reference.

For example, to change the prefix of the log’s file name:

/subsystem=undertow/server=default-server/host=default-host/setting=access-log:write-attribute(name=prefix, value="my_access")

Alternatively, you could change the configuration in the config XML (e.g. standalone.xml):

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    ...
    <server name="default-server">
        ...
        <host name="default-host" alias="localhost">
            ...
            <access-log prefix="my_access" />
            ...
        </host>
    </server>
    ...
</subsystem>

JBoss will now write every access to the application to accesslog in the log directory (e.g. JBOSS_HOME\standalone\log):

192.168.1.1 - - [23/Jun/2016:13:29:24 +0200] "GET /MyApp/MyPath/MyFile.xhtml HTTP/1.1" 200 5738

Logging to webMethod’s Integration Server log from a Java Service

I created a Java Service in webMethod’s Integration Server that should log something to the server.log file. As it turns out, this is quite simple:

  1. Generate Java code for calling the internal Service pub.flow.debugLog by right-clicking on the Service in Software AG Designer and selecting “Generate Code…”, “For calling this service from another service”. The code gets copied to the clipboard automatically.
  2. Paste the code snippet into your Java Service. It may look like this:

    // input IData input = IDataFactory.create(); 
    IDataCursor inputCursor = input.getCursor(); 
    IDataUtil.put( inputCursor, "message", "message" ); 
    IDataUtil.put( inputCursor, "function", "function" ); 
    IDataUtil.put( inputCursor, "level", "level" ); 
    inputCursor.destroy();
    
    // output IData output = IDataFactory.create(); 
    try 
    { 
        output = Service.doInvoke( "pub.flow", "debugLog", input ); 
    } 
    catch( Exception e) {}
    
  3. Now you’ll need a reference to the JAR file containing the needed classes (i.e. com.wm.data.IData, IDataCursor, IDataUtil, and com.wm.app.b2b.server.Service). The former can be found in client.jar (e.g. \SoftwareAG\eclipse\v36\plugins\com.webmethods.process.model.upgrade.impl_8.2.2.0000-0211\lib\client.jar), the latter in wm-isserver.jar (e.g. SoftwareAG\IntegrationServer\lib\wm-isserver.jar). Add the JARs to your project’s build path and your done. Now you should be able to compile your project. I’ve created a short helper method for accessing the logging from a Java Service to get rid of the redundant code snippets:

    public static void logMessageToServerLog(
        IData pipeline, 
        String message, 
        String function, 
        String level) 
        throws ServiceException 
    { 
        IDataCursor inputCursor = pipeline.getCursor(); 
        IDataUtil.put(inputCursor, "message", message); 
        IDataUtil.put(inputCursor, "function", function); 
        IDataUtil.put(inputCursor, "level", level); 
        inputCursor.destroy();
    
        try
        {
            Service.doInvoke("pub.flow", "debugLog", pipeline);
        }
        catch (Exception e)
        {
            throw new ServiceException(e.getMessage());
        }
    }