Sun GlassFish Enterprise Server v3 Prelude Administration Guide

Configuring Log Handler Elements

The following tasks apply to configuring log handler elements:

ProcedureTo Set Handler-Specific Properties

You can modify logging behavior by setting properties in the logging.properties file as follows:

  1. In a text editor, find the property that you want to modify and make your changes.

    The following properties are available:

    File Description

    Contains the name and location of the log file. By default, the name is server.log and the location is the logs directory. These can be changed.

    com.sun.enterprise.server.logging.FileandSyslogHandler.file=logs/server.log
    File Rotation Time Limit

    Rotates the log file based on time in minutes. If defined, time limit takes precedence over size limit. If set to 0 (the default), there is no rotation based on time.

    com.sun.enterprise.server.logging.FileandSyslogHandler.rotationTimelimitInMinutes=0
    File Rotation Size Limit

    Rotates the log file based on limit in bytes. If set to 0 (the default), there is no rotation based on file size. 500000 is the minimum.

    com.sun.enterprise.server.logging.FileandSyslogHandler.rotationLimitInBytes=0
    Formatter

    Uses UniformLogFormatter to format the records in the log file.

    com.sun.enterprise.server.logging.FileandSyslogHandler.formatter=com.
    sun.enterprise.server.logging.UniformLogFormatter
  2. Save the file.

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 9–1 Changing a Handler-Specific Logging Property

The following example changes the rotationTimelimitInMinutes from 0 (the default) to 90 minutes:

Before:


com.sun.enterprise.server.logging.FileandSyslogHandler.rotationTimelimitInMinutes=0

After: :


com.sun.enterprise.server.logging.FileandSyslogHandler.rotationTimelimitInMinutes=90

ProcedureTo Add a Log Handler

A comma-separated list of log handlers is installed during startup of the JavaTM Virtual Machine (JVMTM) host. The default log handler that is provided in the logging. properties file, ConsoleHandler, is configured as follows:


handlers= java.util.logging.ConsoleHandler

In Enterprise Server, the best approach to developing a handler is to define a Hundred-Kilobyte Kernel (HK2) component which implements the handler contract. Enterprise Server registers this handler automatically because it is an HK2 component, and there is no task required of the administrator.

To implement a new handler that is not developed as an HK2 component, you need to add the new handler to the logging.properties file after the developer has put the new handler JAR file into the /lib directory.

  1. In a text editor, add the new file handler to the line that begins with handlers=.

  2. Save the file.

  3. To apply your changes, restart Enterprise Server.

    1. Stop Enterprise Server.

      For instructions, see To Stop a Domain (or Server).

    2. Start Enterprise Server.

      For instructions, see To Start a Domain (or Server).


Example 9–2 Adding a New Log Handler

The following example adds the new logger com.example.logging.MyHandler:

Before:


handlers= java.util.logging.ConsoleHandler

After:


handlers= java.util.logging.ConsoleHandler, com.example.logging.MyHandler