Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Administration Guide

- Previous: About Logging
- Next: Chapter 16 Monitoring Components and Services

# Admin Console Tasks for Logging

- To configure general logging settings

- To configure log levels

- To view the server log

## To configure general logging settings

You can use the `com.sun.enterprise.server.logging.max_history_files` system property to limit the number of rotated log files for both access logging and the server log. The property specifies the maximum number of access log files to keep, starting with the most recent ones.

- If the property is not set, then no history files cleanup is done.

- If the property is set and it's either an invalid number or null, then a default of 10 history files is kept.

- If the property is set to 0, then no history files are kept.

In the Admin Console, access the config/server that this system property needs to be set for. On the command line, use the `create-jvm-option` command.

1. In the tree component, expand the Node Agents or Configurations node.

2. Select a node agent, or select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, for the default instance, `server`, select the `server-config` node.

   - To configure the default settings for future instances that use a copy of `default-config`, select the `default-config` node.

3. For a node agent, select the Logger Settings tab. For a configuration, select the Logger Settings node.

4. On the Logging Settings page, use the following fields to customize logging:

   - Log File — To specify an alternative name or location for the server log file, type the new path name in the text field. By default, the location is domain-dir`/logs/server.log`.

   - Alarms — To route `SEVERE` and `WARNING` messages through the JMX framework, select the Enabled checkbox.

   - Write to System Log — On Solaris and Linux systems only, to send logging output to the `syslog` facility in addition to the server log, select the Enabled checkbox.

   - Log Handler — To send logs to a destination other than `server.log` or `syslog`, you can plug in a custom log handler. The custom handler must extend the class `java.util.logging.Handler` (a JSR 047 compliant API). Type the absolute class name of the handler in the Log Handler field. Also put the handler class in the Application Server classpath so that the handler is installed during server startup. The log records from the custom handler will have the format described in Log Records.

   - Log Filter — To filter log records that are sent to destinations such as `server.log`, `syslog`, or a destination specified by a custom log handler, you can plug in a custom log filter. The custom filter must implement the interface `java.util.logging.Filter`. Type the absolute class name of the filter in the Log Filter field. Also put the filter class in the Application Server classpath so that the filter is installed during server startup.

   - File Rotation Limit: When the server log reaches the specified size in bytes, the logs are rotated and renamed to `server.log_`date, where date is the date and time when the file was rotated. The default value is 2 megabytes. The minimum value for the limit is 500 kilobytes; if you specify a lower value, the file rotates when it reaches 500 KB. To turn off log file rotation, set the value to 0.

   - File Rotation Time Limit — Rotate the server log after the specified number of minutes is reached. The default value is zero, which means that the file is rotated when it reaches the size specified in the File Rotation Limit field. If you specify one or more minutes, the time limit takes precedence over the size limit.

5. Click Save to save changes. Click View Log Files to view the server log.

## To configure log levels

1. In the tree component, expand the Node Agents or Configurations node.

2. Select a node agent, or select the instance to configure:

   - To configure a particular instance, select the instance’s config node. For example, for the default instance, `server`, select the `server-config` node.

   - To configure the default settings for future instances that use a copy of `default-config`, select the `default-config` node.

3. For a node agent, select the Log Levels tab. For a configuration, select the Logger Settings node, then select the Log Levels tab.

4. On the Module Log Levels page, choose a new value from the drop-down list opposite the module or modules whose log level is to be changed.

   The default level is `INFO`, meaning that messages at that level or higher (`WARNING`, `SEVERE`) appear in the log. Choose any of the following values (listed from highest to lowest):

   - `SEVERE`

   - `WARNING`

   - `INFO`

   - `CONFIG`

   - `FINE`

   - `FINER`

   - `FINEST`

   - `OFF`

5. Use the Additional Properties area to configure log levels for any application loggers.

   The property name is the logger namespace, and the value is one of the eight possible levels. For example, the property name could be `samples.logging.simple.servlet`, and the value could be `FINE`.

   Also use this area to change the log level for a submodule, such as the transport submodule of the CORBA module:

       javax.enterprise.resource.corba.ORBId.transport

6. Click Save to save the changes, or click Default to restore the default values.

   Calls to `System.out.println` are logged at the `INFO` level using the logger name `javax.enterprise.system.stream.out`. Calls to `System.err.println` are logged at the `WARNING` level using the logger name `javax.enterprise.system.stream.err`. To turn off the logs from these sources, specify the logger name with the value `OFF` in the Additional Properties area.

   Changes to the Log Level settings take effect immediately. They are also saved in the `domain.xml` file for use when the server restarts.

## To view the server log

1. In the tree component, expand the node for the server instance whose log you want to view.

2. On the General Information page, click View Log Files.

3. Use the Search Criteria area to customize and filter the log viewer. Use the basic fields as follows:

   - Instance Name — Choose an instance name from the drop-down list to view the log for that server instance. The default is the current server instance.

   - Log File — Choose a log file name from the drop-down list to view the contents of that log. The default is `server.log`.

   - Timestamp — To view the most recent messages, select Most Recent (the default). To view messages only from a certain period of time, select Specific Range and type a date and time value in the From and To fields that appear. For the Time value, the syntax must take the following form (SSS stands for milliseconds):

         hh:mm:ss.SSS

     For example:

         17:10:00.000

     If the From value is later than the To value, an error message appears.

   - Log Level — To filter messages by log level, choose a log level from the drop-down list. By default, the display includes all messages that appear in the server log at the chosen log level and more severe levels. Select the checkbox labeled “Do not include more severe messages” to display messages at only the chosen level.

     To ensure that the messages you want to view appear in the server log, first set the appropriate log levels on the Log Levels page. See To configure log levels

     If you choose to filter log messages based on log level, only messages matching the specified filter criteria are shown. However, this filtering does not affect which messages are logged to the server log.

     The most recent 40 entries in the server log appear, with the settings specified on the Logging Settings and Log Levels pages.

     Click the triangle next to the Timestamp header to sort the messages so that the most recent one appears last.

     To view a formatted version of any message, click the link marked

         (details)

     A window labeled Log Entry Detail appears, with a formatted version of the message.

     At the end of the list of entries, click the buttons to view earlier or later entries in the log file.

     Click Advanced Search in the Search Criteria area to make additional refinements to the log viewer. Use the Advanced Options fields as follows:

   - Logger — To filter by module, choose one or more namespaces from the drop-down list. Use shift-click or control-click to choose multiple namespaces.

     Selecting a namespace at a higher level selects all the namespaces below it. For example, selecting `javax.enterprise.system` also selects the loggers for all the modules under that namespace: `javax.enterprise.system.core`, `javax.enterprise.system.tools.admin`, and so on.

   - Custom Logger — To view messages from loggers specific to a particular application, type the logger names in the text field, one per line. If the application has several modules, you can view any or all of them. For example, suppose the application has loggers with the following names:

         com.mycompany.myapp.module1
         com.mycompany.myapp.module2
         com.mycompany.myapp.module3

     To view messages from all modules in the application, type `com.mycompany.myapp`. To view messages from `module2` only, type `com.mycompany.myapp.module2`.

     When you specify one or more custom loggers, messages from Application Server modules appear only if you specify them explicitly in the Logger area.

   - Name-Value Pairs — To view output from a specific thread, type the key name and value for that thread in the text field. The key name is `_ThreadID`. For example:

         _ThreadID=13

     Suppose that `com.mycompany.myapp.module2` runs in several threads. To refine the log viewer to show only the output from a single thread, specify that module’s logger in the Custom Logger field, and then specify the thread ID in this field.

   - Display — To view more than 40 messages at a time (the default), choose another of the available values from the drop-down list (100, 250, or 1000).

     To view stack traces, deselect the “Limit excessively long messages” checkbox. By default, stack traces do not appear in the viewer; to view them, click the `(details)` link for a message.

     Click Basic Search to hide the Advanced Options area.

- Previous: About Logging
- Next: Chapter 16 Monitoring Components and Services

- © 2010, Oracle Corporation and/or its affiliates