12 Managing Logs

Oracle Traffic Director records data about server events such as configuration changes, instances being started and stopped, errors while processing requests, and so on in log files. You can use the logs to diagnose server problems, evaluate server usage patterns, and tune the system for improved performance.

This chapter contains the following sections:

About the Oracle Traffic Director Logs

Each Oracle Traffic Director instance, including the administration server, has two logs—an access log and a server log. The instance logs are enabled by default and initialized when the instance is started for the first time. In addition to the instance logs, you can enable access and server logs for each virtual server in the instance.

  • The default location of the access log and server log for an Oracle Traffic Director instance is the INSTANCE_HOME/net-config_name/logs directory.

  • For the administration server, the default location of the log files is INSTANCE_HOME/admin-server/logs directory.

This section provides an overview of the access and server logs. For information about changing log settings, including the name and location of log files, see Configuring Log Preferences.

Access Log

The access log contains information about requests to, and responses from, the server. The default name of the access log file is access.log.

The following example shows the first three lines in a typical access log:

format=%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] "%Req->reqpb.clf-request%" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length% %Req->vars.ecid%
10.177.243.207 - - [28/Aug/2011:23:28:30 -0700] "GET / HTTP/1.1" 200 4826 -
10.177.243.207 - - [28/Aug/2011:23:28:31 -0700] "GET / HTTP/1.1" 200 916 -

The first line indicates the access log format. The second and third lines are the actual entries.

You can change the access log format, file name, and location. You can also disable the access log. For more information, see Configuring Log Preferences.

Server Log

The server log contains data about lifecycle events—server start-up, shut down, and restart; configuration updates; and so on. It also contains errors and warnings that the server encountered. The default name of the server log file is server.log.

The following line is an example of an entry in a server log.

[2011-10-03T02:04:59.000-07:00] [net-soa] [NOTIFICATION] [OTD-10358] []
 [pid: 11722] http-listener-1: http://example.com:1904 ready to accept requests

The default server-log level is NOTIFICATION:1, at which only major lifecycle events, warnings, and errors are logged.

You can change the log level, the log file name, and the log file location. For more information, see Configuring Log Preferences.

Table 12-1 lists the log levels that you can specify for the server log.

Table 12-1 Server Log Levels

Log Level Description

INCIDENT_ERROR:1

A serious problem caused by unknown reasons. You should contact Oracle for support.

ERROR:1

ERROR:16

ERROR:32

A serious problem that requires your immediate attention.

WARNING:1

A potential problem that you should review.

NOTIFICATION:1 (default)

A major lifecycle event, such as a server being started or restarted.

TRACE:1

TRACE:16

TRACE:32

Trace or debug information to help you or Oracle Support diagnose problems with a particular subsystem.

The number following each log level indicates the severity of the logged event on the scale 1–32. An ERROR:1 message is of higher severity than an ERROR:16 message.

TRACE:32 is the most verbose log level and INCIDENT_ERROR:1 is the least verbose. Enabling the TRACE log levels might affect performance, because of the high volume of messages that are logged. Therefore, avoid enabling verbose log levels in production systems, except in situations when you need more detailed information to debug issues.

Viewing Logs

You can view the access and server logs of Oracle Traffic Director instances and virtual servers by using either the administration console or the CLI.

Note:

  • Besides using the CLI and administration console, you can also use the standard operating-system commands such as ls and more to list and view the log files.

  • The Log Viewer in the administration console and the get-access-log CLI command display only the log entries that currently exist in the access log file on the disk. They do not display items from the access-log buffer (see Configuring Access-Log Buffer Settings)).

  • The CLI examples in this section are shown in shell mode (tadm>). For information about invoking the CLI shell, see Accessing the Command-Line Interface.

Viewing Logs Using the Administration Console

To view log data for a node, an instance, or virtual server within an instance by using the administration console, do the following:

  1. Log in to the administration console, as described in Accessing the Administration Console.
  2. Click the Configurations button that is situated at the upper left corner of the page.

    A list of the available configurations is displayed.

  3. Select the configuration for which you want to view logs.
  4. In the Common Tasks pane, click View Logs.

    The Oracle Traffic Director Log Viewer window is displayed.

  5. Click the Select Node, Instance, or Virtual Server button, and select the node, instance, or virtual server for which you want to view log data.
    • To view the server log, select the Server Log tab.

    • To view the access log, select the Access Log tab.

    To search for specific records, click the Search Options button near the upper right corner of the window, and specify the appropriate filters.

    You can refresh the display by clicking the refresh button near the Search Options button. Note that when you refresh the Log Viewer by clicking the refresh button, the search options and sort order are reset to the default settings.

    If you want the log viewer to be refreshed automatically after every 15 seconds, select the Auto Refresh check box.

Viewing Logs Using the CLI

  • To view the access log for an instance or a virtual server, run the get-access-log command.

    For example, the following command displays the access-log records with status=304 for the instance of the configuration soa running on the node example.com.

    tadm> get-access-log --status-code=304 --config=soa example.com
    format=%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] "%Req->reqpb.clf-request%" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%
    10.177.243.207 - - [25/Aug/2011:04:41:34 -0700] "GET / HTTP/1.1" 304 0
    10.177.243.207 - - [25/Aug/2011:04:41:35 -0700] "GET / HTTP/1.1" 304 0
    

    The first line shows the format that is currently defined for the access log.

    To view the access log for a particular virtual server within the instance, specify the virtual server name by using the --vs option.

  • To view the server log for an instance or a virtual server, run the get-log command.

    For example, the following command displays the server-log records with log level warning:1 or higher for the instance of the configuration soa running on the node example.com.

    tadm> get-log --log-level=warning:1 --config=soa example.com
    

    To view the server log for a particular virtual server within the instance, specify the virtual server name by using the --vs option.

For more information about get-access-log and get-log, see the Oracle Traffic Director Command-Line Reference or run the commands with the --help option.

Configuring Log Preferences

When you create a configuration, the server and access logs are enabled with certain default settings. You can change the server log level, file name, and location. You can change the access log format, file name, and location. You can also disable the access log. If you change the location of the server log, you should restart the instance for the change to take effect.

The log preferences defined in a configuration are applicable to all the virtual servers in the configuration. At the virtual-server level, you can define the access-log location and format, and the server-log location.

You can configure log preferences for Oracle Traffic Director instances by using either the administration console or the CLI.

Note:

Configuring Log Preferences Using the Administration Console

To configure log preferences for a configuration or a virtual server by using the administration console, do the following:

  1. Log in to the administration console, as described in Accessing the Administration Console.
  2. Click the Configurations button that is situated at the upper left corner of the page.

    A list of the available configurations is displayed.

  3. Select the configuration for which you want to configure log preferences.
    • To change log preferences for the entire configuration, select Logging in the navigation pane.

    • To set or change the log preferences for a specific virtual server in the configuration, expand Virtual Servers in the navigation pane, select the virtual server for which you want to define log preferences, and then select Logging.

    The Log Preferences page is displayed.

  4. Specify the parameters that you want to change.

    On-screen help and prompts are provided for all of the parameters.

    For information about specifying a custom access-log format, see "Using the Custom Access-Log Format" in the Oracle Traffic Director Configuration Files Reference.

    When you change the value in a field or tab out of a text field that you changed, the Save button near the upper right corner of the page is enabled.

    At any time, you can discard the changes by clicking the Reset button.

  5. After making the required changes, click Save.
    • A message, confirming that the updated configuration was saved, is displayed in the Console Messages pane.

    • In addition, the Deployment Pending message is displayed at the top of the main pane. You can either deploy the updated configuration immediately by clicking Deploy Changes, or you can do so later after making further changes as described in Deploying a Configuration.

Configuring Log Preferences Using the CLI

  • To view the current access-log preferences for a configuration or a virtual server, run the get-access-log-prop command.

    For example, the following command displays the access-log preferences for the configuration soa.

    tadm> get-access-log-prop --config=soa
    enabled=true
    file=../logs/access.log
    format=%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] "%Req->reqpb.clf-request%" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length% %Req->vars.ecid%
    mode=text
    

    To view the access-log preferences for a particular virtual server in the configuration, run get-access-log-prop with the --vs option.

  • To set or change access-log preferences for a configuration or a virtual server, run the enable-access-log command.

    For example, the following command changes the location of the access log for the configuration soa to INSTANCE_HOME/net-config_name/logs/access.

    tadm> enable-access-log --config=soa --file=../logs/access
    OTD-70201 Command 'enable-access-log' ran successfully.
    

    Note:

    If you specify a relative path for the log-file directory, the path is taken to be relative to the config directory of the instance.

    To set or change the access-log location and format for a particular virtual server in the configuration, run enable-access-log with the --vs option.

    For information about specifying a custom access-log format, see "Using the Custom Access-Log Format" in the Oracle Traffic Director Configuration Files Reference.

  • To disable the access log for a configuration or a virtual server, run the disable-access-log command, as shown in the following example:

    tadm> disable-access-log --config=soa
    OTD-70201 Command 'disable-access-log' ran successfully.
    

    To disable the access log for a particular virtual server in the configuration, run disable-access-log with the --vs option.

  • To view the current server-log preferences for a configuration, run the get-log-prop command.

    For example, the following command displays the server-log preferences for the configuration soa.

    tadm> get-log-prop --config=soat
    create-console=false
    log-file=../logs/server.log
    log-to-syslog=false
    log-virtual-server-name=false
    log-stdout=true
    log-level=NOTIFICATION:1
    log-to-console=true
    log-stderr=true
    
  • To view the server-log location for a particular virtual server in a configuration, run the get-virtual-server-prop command, as shown in the following example:

    tadm> get-virtual-server-prop --config=soa --vs=vs1 log-file
    
  • To set or change server-log preferences for a configuration, run the set-log-prop command. Note that if you change the location of the server log, you should restart the instance for the change to take effect.

    For example, the following command changes the server-log level for the configuration soa to WARNING:1.

    tadm> set-log-prop --config=soa log-level=WARNING:1
    OTD-70201 Command 'set-log-prop' ran successfully.
    
  • To set or change server-log preferences for a virtual server, run the set-virtual-server-prop command.

    For example, the following command changes the server-log location for the virtual server vs1 in the configuration soa to INSTANCE_HOME/net-config_name/log/server.

    tadm> set-virtual-server-prop --config=soa --vs=vs1 log-file=../log/server
    OTD-70201 Command 'set-virtual-server-prop' ran successfully.
    

    Note:

    If you specify a relative path for the log-file directory, the path is taken to be relative to the config directory of the instance.

For the updated configuration to take effect, you should deploy it to the Oracle Traffic Director instances by using the deploy-config command. If you change the location of the server log, you should restart the instance for the change to take effect

For more information about the CLI commands mentioned in this section, see the Oracle Traffic Director Command-Line Reference or run the commands with the --help option.

About Log Rotation

You can configure Oracle Traffic Director to automatically rotate (archive) the logs at specified intervals. You can also rotate the logs manually whenever required.

When the logs are rotated, the old log files are renamed with a suffix indicating the rotation date (in the yyyymmdd format) and 24-hour time (in the hhmm format). For example, the file name of the server log archive created at 11 p.m. on August 25, 2011 would be server-201108252300.log.

After log rotation, the server and access logs are re-initialized.

For information about how to rotate logs, see Rotating Logs Manually and Configuring Oracle Traffic Director to Rotate Logs Automatically.

Note:

Rotate Access Log event will also rotate TCP access logs.

Rotating Logs Manually

You can rotate the server and access logs of Oracle Traffic Director instances manually by using either the administration console or the CLI.

Note:

The CLI examples in this section are shown in shell mode (tadm>). For information about invoking the CLI shell, see Accessing the Command-Line Interface.

Rotating Logs Manually Using the Administration Console

To rotate logs by using the administration console, do the following:

  1. Log in to the administration console, as described in Accessing the Administration Console.

  2. Click the Configurations button that is situated at the upper left corner of the page.

    A list of the available configurations is displayed.

  3. Select the configuration for which you want to rotate logs.

    To rotate logs for all the instances of the selected configuration, do the following:

    1. In the navigation pane, select Logging.

      The Log Preferences page is displayed.

    2. Go to the Log Rotation section of the page.

    3. If you want Oracle Traffic Director to run a specific command on the rotated log files, specify the absolute path to the required command in the Archive Command field.

      For example, if you specify /usr/bin/gzip as the archive command, after rotating the logs, Oracle Traffic Director compresses the rotated log files by running the following commands:

      $ /usr/bin/gzip access-yyyymmddhhmm.log
      $ /usr/bin/gzip server-yyyymmddhhmm.log
      
    4. Click Rotate Logs Now.

      The server and access logs, including any virtual server-specific logs, for all the instances of the configuration are archived.

    To rotate logs for a specific instance of the selected configuration, do the following:

    1. In the navigation pane, select Instances.

      The Instances page is displayed.

    2. Click the Rotate Logs button for the required instance.

      The server and access logs, including any virtual server-specific logs, for the selected instance are archived.

    A message is displayed in the Console Messages pane confirming that the logs were rotated.

Rotating Logs Manually Using the CLI

To rotate logs for one or more instances of a configuration, run the rotate-log command.

For example, the following command rotates the access and server logs, including any virtual server-specific logs, for the instance of the configuration soa running on the nodes soa1.example.com and soa2.example.com.

tadm> rotate-log --config=soa soa1.example.com soa2.example.com
OTD-70201 Command 'rotate-log' ran successfully.

If you do not specify any node, the logs are rotated for all the instances of the configuration.

Note:

If you want Oracle Traffic Director to run a specific command on the rotated log files, specify the absolute path to the required command by running the set-log-prop command as shown in the following example:

tadm> set-log-prop --config=soa archive-command=/usr/bin/gzip
OTD-70201 Command 'set-log-prop' ran successfully.

In this example, after rotating the logs, Oracle Traffic Director compresses the rotated log files by running the following commands:

$ /usr/bin/gzip access-yyyymmddhhmm.log
$ /usr/bin/gzip server-yyyymmddhhmm.log

For more information about rotate-log and set-log-prop, see the Oracle Traffic Director Command-Line Reference or run the command with the --help option.

Configuring Oracle Traffic Director to Rotate Logs Automatically

You can configure Oracle Traffic Director to rotate logs automatically at specified times or intervals by creating log-rotation events.

You can create log-rotation events by using either the administration console or the CLI.

Note:

The CLI examples in this section are shown in shell mode (tadm>). For information about invoking the CLI shell, see Accessing the Command-Line Interface.

Oracle Java Cloud Service configures Oracle Traffic Director to rotate logs automatically when you create an Oracle Java Cloud Service instance with a load balancer or add a load balancer to an Oracle Java Cloud Service instance.

Creating Log-Rotation Events Using the Administration Console

To create log-rotation events by using the administration console, do the following:

  1. Log in to the administration console, as described in Accessing the Administration Console.
  2. Click the Configurations button that is situated at the upper left corner of the page.

    A list of the available configurations is displayed.

  3. Select the configuration for which you want to create log-rotation events.
  4. In the navigation pane, select Logging.

    The Log Preferences page is displayed.

  5. Go to the Log Rotation section of the page.
  6. If you want Oracle Traffic Director to run a specific command on the rotated log files, specify the absolute path to the required command in the Archive Command field.

    For example, if you specify /usr/bin/gzip as the archive command, after rotating the logs, Oracle Traffic Director compresses the rotated log files by running the following commands:

    $ /usr/bin/gzip access-yyyymmddhhmm.log
    $ /usr/bin/gzip server-yyyymmddhhmm.log
    
  7. Click New Event.

    The New Log Rotation Event dialog box is displayed.

  8. Specify whether the event is for the server log or the access log.
  9. Specify the interval or time of the day at which the log should be updated, and then click OK.
    • A message, confirming creation of the event, is displayed in the Console Messages pane.

    • The new event is displayed in the Log Rotation Events list.

      • New events are enabled by default. To change the status, select the Enable/Disable check box.

      • To delete an event, click the Delete button.

    • In addition, the Deployment Pending message is displayed at the top of the main pane. You can either deploy the updated configuration immediately by clicking Deploy Changes, or you can do so later after making further changes as described in Deploying a Configuration.

Creating Log-Rotation Events Using the CLI

To create log-rotation events, run the create-event command.

For example, the following commands configure Oracle Traffic Director to rotate the access logs and server logs for all instances of the configuration soa after every 3600 seconds and 7200 seconds respectively.

tadm> create-event --config=soa --command=rotate-access-log --interval=3600
OTD-70201 Command 'create-event' ran successfully.

tadm> create-event --config=soa --command=rotate-log --interval=7200
OTD-70201 Command 'create-event' ran successfully.

Note:

If you want Oracle Traffic Director to run a specific command on the rotated log files, specify the absolute path to the required command by running the set-log-prop command as shown in the following example:

tadm> set-log-prop --config=soa archive-command=/usr/bin/gzip
OTD-70201 Command 'set-log-prop' ran successfully.

In this example, after rotating the logs, Oracle Traffic Director compresses the rotated log files by running the following commands:

$ /usr/bin/gzip access-yyyymmddhhmm.log
$ /usr/bin/gzip server-yyyymmddhhmm.log

For the updated configuration to take effect, you should deploy it to the Oracle Traffic Director instances by using the deploy-config command.

For more information about create-event, see the Oracle Traffic Director Command-Line Reference or run the command with the --help option.