Sun Java System Web Server 6.1 SP9 Administrator's Guide

Setting Access Log Preferences

During installation, the accesslog file is created for the server. You can customize access logging for any resource by specifying whether or not to log accesses, the format to use for logging, and whether or not the server should spend time looking up the domain names of clients when they access a resource.

To add %vsid% to the log file format string:

ProcedureTo add the %vsid% to the log file format string

  1. Access the Server Manager and choose the Logs tab.

  2. Click the Access Log Preferences link.

  3. Enter a new log file location and filename in the Log File: text box.

  4. Click the Only Log: radio button.

  5. Click the Virtual Server Id check box. Alternately click the Custom Format: radio button and add the string ”%vsid%.

    Note –

    When adding the custom format string ”%vsid%, you must use a new access log file.

    When changing the format of an existing log file, you should first delete/rename the existing log file OR use a different file name.

    Server access logs can be in Common Logfile Format, flexible log format, or your own customizable format. The Common Logfile Format is a commonly supported format that provides a fixed amount of information about the server. The flexible log format allows you to choose (from Sun Java System Web Server) what to log. A customizable format uses parameter blocks that you specify to control what gets logged. For a list of customizable format parameters, see the Sun Java System Web Server 6.1 SP9 NSAPI Programmer’s Guide.

    Once an access log for a resource has been created, you cannot change its format unless you archive it or create a new access log file for the resource.

    You can specify logging preferences using the Access Log Preferences page in the Server Manager, or you can manually configure the following directives in the obj.conf file. In the magnus.conf file, the server calls the flex-init function to initialize the flexible logging system and the flex-log function to record request-specific data in a flexible log format. To log requests using the common log file format, the server calls init-clf to initialize the Common Log subsystem which is used in the obj.conf, and the common-log to record request-specific data in the common log format (used by most HTTP servers).

    For more information on the NSAPI logging functions, including valid directives and parameters, see the Sun Java System Web Server 6.1 SP9 NSAPI Programmer’s Guide.

Easy Cookie Logging

The Sun Java System Web Server has an easy way to log a specific cookie using the flexlog facility. Add Req->headers.cookie.cookie_name to the Init fn=flex-init line in the magnus.conf file. This logs the value of the cookie variable cookie_name if the cookie variable is present in the request header, and logs - if it is not present.

Example 10–1 To log all cookies

Init fn=flex-init format.access="%Ses->client.ip% - %Req->vars.auth-user%
[%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status%
%Req->srvhdrs.content-length% %Req->headers.cookie.jsessionid%""

Note –

All cookie names and header names must be in lowercase.