Previous Next Contents Index


Chapter 5

Logging Server Messages

This chapter describes the message-logging service provided by Netscape Application Server.

The following topics are included in this chapter:


About the Logging Service
You can log server messages using the Netscape Application Server (NAS) message-logging service. The logging service is configured through the NAS Administrator Logging window. There you can specify the destination and types of messages logged.

When you enable logging, NAS records messages generated by NAS application-level and system-level services. These messages describe the events that occur while a service is running. For example, each time NAS communicates with the database, the logging service records the resulting messages generated by database access service.

Determining Types of Messages to Log You can log any of the three types of messages generated by NAS services. Each type is described in the following table:

Message type
Description
When it might appear
Information message
Describes the processing of a request or normal service activity, such as a status update.
When no problems arise.
Warning message
Describes a noncritical problem that might be an indication to a larger problem.
When a service encounters a temporary problem, such as when it is unable to connect to a process.
Error message
Describes a critical failure of the service, from which recovery is not likely.
When a service encounters a critical problem, such as a pipe closure.

With the logging service, you can record error messages, error and warning messages, or all messages. To choose which type of messages to log, perform the following steps:

  1. Click the Logging button on the NAS Administrator toolbar to open the Logging window.
  2. Select the Enable Server Event Log checkbox as shown in the following figure:
  3. In the General area, from the Message Type drop-down box, select Errors, Errors and Warnings, or All Messages.
  4. In the Maximum Entries text field, enter the maximum number of entries that can exist before data is written to the log.
  5. In the Write Interval text field, enter the amount of time (in seconds) that elapses before data is written to the log.
Logging Application Messages
Message logging is also useful for tracking and debugging application errors. By using the log( ) method, application developers can send messages to the same log destination the server administrator configures for NAS services.

For example, if an application encounters a problem in a segment of code, you can log the associated error message. Informational messages about the application's status, rather than error messages, are also useful.

How Log Messages Are Formatted
Every log message has the following four components:

Two of these components, the message type and the service or application component ID, are stored as numbers in a database table. The logging service maps those numbers to a string when sending the message to the other three destination logs.

A log message uses the following syntax when it is sent to a process console, an ASCII text file, or the application log:

For example, the following messages sent to an ASCII text file illustrate message format:

Determining the Logging Destination You can configure the logging service to record server and application messages in any or all of the destinations described in the following table:

Log destination
Description
When to use
Process consoles
The NAS process consoles display log messages as they are generated.
This is the default. If logging is enabled and the server is enabled for automatic startup (UNIX) or interaction with the desktop (NT), the consoles open and display the log messages. You can disable this feature by deselecting the Log to Console checkbox.
Application log
The default application log file. For Windows NT, this is viewable through the Event Viewer.
This is the default. Provides a more comprehensive record of the server and application error messages. Warning and information messages are not logged to the application log. All messages are sorted by their timestamp.
ASCII text file
An ASCII text file, which you must create and specify.
Use when you want a more permanent record of the server and application messages. All messages are sorted by their timestamp.
Database table
A database table which you must create and specify.
This is the most versatile logging destination. Use when you want to sort, group, and create reports of the logged messages.

When you enable logging, the logging service automatically sends messages to the process consoles on Windows NT and Unix platforms, as long as those consoles are open and console logging in enabled. On Windows NT, the logging service also sends messages to the application log. Logging to a process console does not record the messages. You cannot retrieve the messages once they scroll off of the screen.

To enable the logging service and specify the destination of the log messages, perform the following steps:

  1. Click the Logging button on the NAS Administrator toolbar to open the Logging window.
  2. Select the Enable Server Event Log checkbox.
  3. In the Log Target box, choose the type of logging to enable by clicking the Log to a Database, Log to Windows NT Application Log (Errors Only), and/or Log to File checkbox(es). You can disable console logging by deselecting the Log to Console checkbox.
NAS uses a log buffer to store messages before they are written to the application log, an ASCII file, and/or database logs. This buffer optimizes the performance of the application server by limiting the use of resources to continually update a log. The buffer is written to the destination when either the buffer interval times out or the number of entries in the buffer exceeds the maximum number allowed.

Logging to a Database
If you plan to log application server messages to a database, you need to create an event log database table. The following table describes the four field names and lists each field's data type.

Note. On a UNIX system, you can use supplied scripts that automatically set up the eventlog and httplog tables. The scripts are located in the directory $GX_ROOTDIR/APPS/GXApp/Logging/db, and are named Log_db2.sql, Log_ifmx.sql, Log_mssql.sql, Log_ora.sql, and Log_syb.sql. Choose the script that is appropriate for the database you're using.

Database field name
Description
Data type
evttime
Date and time the message was created
Date/Time
evttype
Message type, such as information, warning, or error
Number
evtcategory
Service or application component ID
Number
evtstring
Message text
Text

The logging service maps the message components to the database fields listed in the table. You must use these exact field or column names in your database table.

To log to database, perform following steps:

  1. Click the Logging button on the NAS Administrator toolbar to open the Logging window.
  2. Select the Enable Server Event Log checkbox as shown in the following figure:
  3. In the General area, from the Message Type drop-down box, select Errors, Errors and Warnings, or All Messages.
  4. In the Log Target area, click the Log to Database checkbox.
  5. Click the Apply Changes button to save your changes to NAS Administrator.
Logging to a File
NAS Administrator's monitoring service allows you to log information about server activity to a file.

To log information to a file, perform the following steps:

  1. Click the Logging tab on the NAS Administrator toolbar to open the Logging window.
  2. Select the Enable Server Event Log checkbox.
  3. In the General area, from the Message Type drop-down box, select Errors, Errors and Warnings, or All Messages.
  4. In the Log Target area, select the Log to File checkbox.
  5. In the Log to File text field, enter the name of the log file.
  6. Click Apply Changes to save your changes to NAS Administrator.
Rotating Log Files
If you choose to record server messages in an ASCII file, you can enable log file rotation to regulate when log files are rotated. Since log files are stamped with the time and date they are created, log file rotation helps organize log files into manageable units.

To configure log file rotation, perform the following steps:

  1. Click the Logging button on the NAS Administrator toolbar to open the Logging window.
  2. Select the Enable Server Event Log checkbox.
  3. In the General area, from the Message Type drop-down box, select Errors, Errors and Warnings, or All Messages.
  4. Click the Log to File checkbox.
  5. In the Enable File Rotation drop-down box, choose Yes.
  6. From the Rotation Interval drop-down box, select the interval at which log files are rotated or enter a string to indicate when the log file is rotated.
  7. Click Apply Changes to save your changes to the NAS Administrator.

About Web Server Requests
You can use the Netscape Application Server (NAS) logging service to log web server requests. Web server requests are monitored by the web connector plug-in. The plug-in sends requests to your NAS machine where they are processed. By logging web server requests, you can track request patterns and other important request information.

How Web Requests Are Logged Note. On a UNIX system, you can use supplied scripts that automatically set up the HTTP log and event log tables. See Logging to a Database for more information.

Each HTTP variable must be mapped to a database field name within a table that you create. For instance, to log the length of the content of a web server request, map the CONTENT_LENGTH variable to a database field named, for example, content_length and defined as a text data type. The default HTTP variables used by NAS and their database data types are listed in the following table. Use this table to help you create the database table for logging web requests.

Default HTTP variables
Default database field name
Data type
Not applicable
logtime
Date/Time
CONTENT_LENGTH
content_length
Number
CONTENT_TYPE
content_type
Text
HTTP_ACCEPT
accept
Text
HTTP_CONNECTION
connection
Text
HTTP_HOST
host
Text
HTTP_REFERER
referer
Text
HTTP_USER_AGENT
user_agent
Text
PATH_INFO
uri
Text
REMOTE_ADDR
ip
Text
REQUEST_METHOD
method
Text
SERVER_PROTOCOL
protocol
Text

You must have a field name called logtime in the database table. The time the message is created is assigned by the logging service. The logging service maps that time to the logtime database field. You can rename all of the other database field names.

The fields from the database table are automatically mapped to web server variables in the registry

You must have a web server communication plug-in module such as NSAPI or ISAPI installed and properly configured. Even though this happens automatically during installation, there may be occasions when you must manually configure the web server.

Logging Web Server Requests Before you can log web server requests, you must create a database table to hold the request messages. For more information about creating this table, see How Web Requests Are Logged.

To log web server requests, perform the following steps:

  1. Click the Logging button on the NAS Administrator toolbar to open the Logging window.
  2. From the left pane of the Logging window, select the application server responsible for logging web server requests.
  3. In the right pane of the logging window, click the HTTP Log tab.
  4. Enter httplog in the Data Source field.
  5. Enter the information you use to connect to the database in the Database field. For example, this would be the Oracle SID for an Oracle database.
  6. In the Table Name field, enter httplog.
  7. Enter the user name and passwords with which you connect to the database.Enter the maximum entries.
  8. Enter the write interval.
  9. To enable database logging of web server requests, select Log to a Database.
  10. Click Apply Settings to save your changes to your application server.

 

© Copyright 1999 Netscape Communications Corp.