HTTP access logging

You can configure access log settings for HTTP endpoints.

Open Liberty The most current documentation for HTTP access logging in Liberty is available on the Open Liberty website.

HTTP access log settings

An HTTP access log contains a record of all inbound client requests handled by HTTP endpoints. You can enable access logging in the HTTP server, or you can enable it in the Liberty server in two modes: one log common to multiple endpoints, or one log for each endpoint.
Note: If you do not specify attributes, the defaults are used. To see a list of the default attributes, see httpAccessLogging in the list of Liberty configuration elements in Java Servlets 3.0.
  • Using a common log

    To enable logging for multiple endpoints with common settings, include httpAccessLogging as a top-level element in your server.xml file, and then reference it from multiple httpEndpoint elements:

    <httpAccessLogging id="accessLogging"/>
    <httpEndpoint id="defaultHttpEndpoint" accessLoggingRef="accessLogging"/>
    <httpEndpoint id="otherHttpEndpoint" accessLoggingRef="accessLogging" httpPort="9081" httpsPort="9444"/>
  • Using distinct logs for each endpoint

    To enable logging for individual endpoints, use an accessLogging child element and specify a file path that does not conflict with other logs:

    
    <httpEndpoint id="defaultHttpEndpoint">
        <accessLogging filepath="${server.output.dir}/logs/http_defaultEndpoint_access.log"/>
    </httpEndpoint>
  • Using logs for the HTTP server

    For a list of the available HTTP server-side properties and their descriptions, see Apache Module mod_log_config.

HTTP access log format

For a list of the available log format properties and their descriptions, see the accessLogFormat configuration for WebSphere® Application Server in HTTP transport channel custom properties. This log format string is specified by using the logFormat attribute of httpAcccessLogging or accessLogging elements in the server.xml file:

<httpAccessLogging logFormat='%h %u %{t}W "%r" %s %b'/>

or


<httpEndpoint id="defaultHttpEndpoint">
   <accessLogging filepath="${server.output.dir}/logs/http_defaultEndpoint_access.log"
                  logFormat='%h %i %u %t "%r" %s %b' />
</httpEndpoint>

Writing HTTP access log to console or message log using JSON format

When the access log is enabled, a copy of the access logs can be written to the console or to the message log in the JSON format. For example, to send access log events and message log events to the console in JSON format, set the following properties in your bootstrap.properties file:
com.ibm.ws.logging.console.format=json
com.ibm.ws.logging.console.source=accessLog,message