Sun Java System Application Server 8 2004Q4 Beta Platform Edition Administration Guide |
Chapter 14
Configuring LoggingThis chapter briefly describes how to use the Admin Console to configure logging and view the server log. It contains the following sections:
About LoggingLog Records
The Application Server uses the Java 2 platform Logging API specified in JSR 047. Application Server logging messages are recorded in the server log, normally found at install_dir
/domains/domain1/logs/server.log
.In the install_dir
/domains/domain1/logs
directory are two other kinds of logs in addition to the server log. In theaccess
subdirectory are the HTTP Service access logs, and in thetx
subdirectory are the Transaction Service logs. For information about these logs, see "Configuring the HTTP Service Access Log" and "Configuring Transactions".The components of the Application Server generate logging output. Application components can also generate logging output.
Log records follow a uniform format:
[#|yyyy-mm-ddThh:mm:ss.SSS-Z|Log Level|ProductName_Version|LoggerName|Key Value Pairs|Message|#]
For example:
[#|2004-07-29T11:43:43.516-0500|INFO|sun-appserver-pe8.1|javax.enterprise. system.core|_ThreadID=14;|CORE5004: Resource Deployed: [ccp:jms/DurableTopicConnectionFactory].|#]
In this example,
[#
and#]
mark the beginning and end of the record.- The vertical bar (
|
) separates the record fields.- 2004-07-29T11:43:43.516-0500 specifies the date and time.
- The Log Level is
INFO
. This level may have any of the following values:SEVERE
,WARNING
,INFO
,CONFIG
,FINE
,FINER
, andFINEST
.- The ProductName_Version is
sun-appserver-pe8.1
.- The LoggerName is a hierarchical logger namespace that identifies the source of the log module, in this case
javax.enterprise.system.core
. All logger names begin with eitherjavax.enterprise.system
orjavax.enterprise.core
.- The Key Value Pairs are key names and values, typically a thread ID such as
_ThreadID=14;
.- The Message is the text of the log message. For all Application Server
SEVERE
andWARNING
messages and manyINFO
messages, it begins with a message ID that consists of a module code and a numerical value (in this case,CORE5004
).The log record format might be changed or enhanced in future releases.
The Logger Namespace Hierarchy
The Application Server provides a logger for each of its modules. The following table lists the names of the modules and the namespace for each logger in the order in which they appear on the Log Levels page of the Admin Console (see "Configuring Log Levels"). The last three modules in the table do not appear on the Log Levels page.
Admin Console Tasks for LoggingConfiguring General Logging Settings
- In the tree component, select the Application Server node.
- Click the Logging tab.
- 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 install_dir
/domains/domain1/logs/server.log
.- Alarms: To route
SEVERE
andWARNING
messages through the JMX framework, select the Enabled checkbox.- Log Messages to Standard Error: To send logging messages to both standard error and the server log file whether or not the
--verbose
option is specified at Application Server startup, select the Enabled checkbox. By default, if the--verbose
option is not specified, the messages go only to the server log file.- Write to System Log: On Solaris systems only, to send logging output to the Solaris
syslog
facility in addition to the server log, select the Enabled checkbox.- Log Handler: To send logs to a destination other than
server.log
orsyslog
, it is possible to plug in a custom log handler. The custom handler must extend the classjava.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, it is possible to plug in a custom log filter. The custom filter must implement the interfacejava.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, create a new, empty file named
server.log
and rename the old fileserver.log_
date, where date is the date and time when the file was rotated. The default value is 2 gigabytes. The minimum value for the limit is 500 kilobytes; if you specify a lower value, the file rotates when it reaches 500 Kbytes.- 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.
- Click Save to save your changes.
- Stop and restart the Application Server.
Configuring Log Levels
- In the tree component, select the Application Server node.
- Click the Logging tab.
- On the Logging Settings page, click the Log Levels tab.
- 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):- 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 beFINE
.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
- Click Save to save the changes, or click Load Defaults to restore the default values.
Calls to
System.out.println
are logged at theINFO
level using the logger namejavax.enterprise.system.stream.out
. Calls toSystem.err.println
are logged at theWARNING
level using the logger namejavax.enterprise.system.stream.err
. To turn off the logs from these sources, specify the logger name with the valueOFF
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.Viewing 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
Click Modify Search to customize and filter the log viewer. Use the 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.
- 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. For the Time value, the syntax must take the following form (SSS stands for milliseconds):
hh:mm:ss.SSS
By default, all log levels are shown. 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. To ensure that the messages you want to view appear in the log file, first set the appropriate log levels on the Log Levels page. See "Configuring Log Levels".
- Custom Logger: To view messages from loggers specific to your application, type the logger names in the text field, one per line. If your 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