Customizing the Weblogic HTTP access log

You can customize the format of the default HTTP access log.

By default, WebLogic Server keeps a log of all HTTP transactions in a text file. The file is named access.log and is located in the $DOMAIN_HOME/servers/AdminServer Or Managed_Server/logs directory.

The log provides true timing information from WebLogic, in terms of how long each individual Endeca Server request takes. This timing information can be important in troubleshooting a slow system.

Note that this setup needs to be done on a per-server basis. That is, in a clustered environment, this has to be done for the Admin Server and for every Managed Server. This is because the clone operation (done when installing a clustered environment) carries over SSL configuration, but does not carry over access log configuration.

The default format for the file is the common log format, but you can change it to the extended log format, which allows you to specify the type and order of information recorded about each HTTP communication. This topic describes how to add the following identifiers to the file:

  • date — Date on which transaction completed, field has type <date>, as defined in the W3C specification.
  • time — Time at which transaction completed, field has type <time>, as defined in the W3C specification.
  • time-taken — Time taken for transaction to complete in seconds, field has type <fixed>, as defined in the W3C specification.
  • cs-method — The request method, for example GET or POST. This field has type <name>, as defined in the W3C specification.
  • cs-uri — The full requested URI. This field has type <uri>, as defined in the W3C specification.
  • sc-status — Status code of the response, for example (404) indicating a “File not found” status. This field has type <integer>, as defined in the W3C specification.

To customize the HTTP access log:

  1. Log into the Administration Server console.
  2. In the Change Center of the Administration Console, click Lock & Edit.
  3. In the left pane of the Console, expand Environment and select Servers.
  4. In the Servers table, click the AdminServer name.
  5. In the Settings for AdminServer page, select Logging > HTTP.
  6. On the Logging > HTTP page, make sure that the HTTP access log file enabled checkbox is checked.
  7. Click Advanced.
  8. In the Advanced pane:
    1. In the Format list box, select Extended.
    2. In the Extended Logging Format Fields, enter this space-delimited string:
      date time time-taken cs-method cs-uri sc-status
  9. Click Save.
  10. In the Change Center of the Administration Console, click Activate Changes.
  11. Stop and then re-start WebLogic Server.

The following is an example of the configured HTTP access log with several log entries:

#Version:	1.0
#Fields:	date time time-taken cs-method cs-uri sc-status
#Software:	WebLogic
#Start-Date:	2013-10-22	15:23:40
2013-10-22	15:27:07	0.967	POST	/endeca-server/ws/manage	200
2013-10-22	15:27:32	7.301	POST	/endeca-server/es/control	200
2013-10-22	15:27:32	7.567	POST	/endeca-server/ws/manage	200
2013-10-22	16:23:35	0.219	GET	/endeca-server/ws/conversation/sh?wsdl	200
2013-10-22	16:23:35	0.0	GET	/favicon.ico	404
2013-10-22	16:24:14	0.031	GET	/endeca-server/ws/conversation/sh?wsdl	200
2013-10-22	16:24:14	0.031	GET	/endeca-server/ws/conversation/sh?XSD=lql_parser_types.xsd	200
2013-10-22	16:27:15	5.692	POST	/endeca-server/ws/conversation/sh	200
2013-10-22	16:27:50	0.624	POST	/endeca-server/ws/conversation/sh	200

Note that all the queries were successful (status code of 200), except for the one with the 404 status code.

There is no Userid identifier that you can add by default but you can create one,

How to add UserId field to the access log

  1. Write a java class,
import weblogic.servlet.logging.CustomELFLogger;
 import weblogic.servlet.logging.FormatStringBuffer;
 import weblogic.servlet.logging.HttpAccountingInfo;

public class UserId implements CustomELFLogger {
        
         public void logField(HttpAccountingInfo metrics, FormatStringBuffer buff) {
             buff.appendValueOrDash(metrics.getRemoteUser());
     }

}

2. Create a jar file (Using Eclipse etc.)

3. Add this created jar to the Weblogic Classpath (For example add in domain/lib dir)

4. Add a fully-qualified class name with x-

date x-UserId time time-taken cs-method cs-uri sc-status

3. Restart server(s), and you will notice the logged in userid if there is one in the access logs.