Chapter 17 Configuring
Logging
This chapter briefly describes how to configure logging and view the
server log. It contains the following sections:
About Logging
Log Records
The Application Server uses the Java EE platform Logging API specified in
JSR 047. Application Server logging messages are recorded in the server log, normally
found at domain-dir/logs/server.log. When the server log
reaches the specified size in bytes, the log is rotated and renamed to ogserver.log_date, where date is
the date and time when the file was rotated.
The domain-dir/logs directory contains two other
kinds of logs in addition to the server log. In the access subdirectory
are the HTTP Service access logs, and in the tx subdirectory
are the Transaction Service logs. For information about these logs, see Configuring Transactions.
The components of the Application Server generate logging output. Application
components can also generate logging output.
Application components may use the Apache Commons Logging Library to
log messages. The platform standard JSR 047 API, however, is recommended for
better log configuration.
Log records follow a uniform format:
[#|yyyy-mm-ddThh:mm:ss.SSS-Z|Log Level|ProductName-Version|LoggerName|Key Value Pairs|Message|#]
For example:
[#|2006-10-21T13:25:53.852-0400|INFO|sun-appserver9.1|javax.enterprise.
system.core|_ThreadID=13;|CORE5004: Resource Deployed:
[cr:jms/DurableConnectionFactory].|#]
In this example,
-
[# and #] mark the beginning
and end of the record.
-
The vertical bar (|) separates the record
fields.
-
2006-10-21T13:25:53.852-0400 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, and FINEST.
-
The ProductName-Version is sun-appserver9.1.
-
The LoggerName is a hierarchical logger
namespace that identifies the source of the log module, in this case javax.enterprise.system.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 and WARNING messages
and many INFO 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
alphabetical order, as 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.
Table 17–1 Application Server Logger
Namespaces
|
Module Name
|
Namespace
|
|
Admin
|
javax.enterprise.system.tools.admin
|
|
Classloader
|
javax.enterprise.system.core.classloading
|
|
Configuration
|
javax.enterprise.system.core.config
|
|
Connector
|
javax.enterprise.resource.resourceadapter
|
|
CORBA
|
javax.enterprise.resource.corba
|
|
Deployment
|
javax.enterprise.system.tools.deployment
|
|
EJB Container
|
javax.enterprise.system.container.ejb
|
|
Group Management Service (cluster and enterprise profiles only)
|
javax.ee.enterprise.system.gms
|
|
JavaMail
|
javax.enterprise.resource.javamail
|
|
JAXR
|
javax.enterprise.resource.webservices.registry
|
|
JAXRPC
|
javax.enterprise.resource.webservices.rpc
|
|
JAXWS
|
javax.enterprise.resource.webservices.javaws
|
|
JBI
|
com.sun.jbi
|
|
JMS
|
javax.enterprise.resource.jms
|
|
JTA
|
javax.enterprise.resource.jta
|
|
JTS
|
javax.enterprise.system.core.transaction
|
|
MDB Container
|
javax.enterprise.system.container.ejb.mdb
|
|
Naming
|
javax.enterprise.system.core.naming
|
|
Persistence
|
oracle.toplink.essentials, javax.enterprise.resource.jdo, javax.enterprise.system.container.cmp
|
|
Node Agent (cluster and enterprise profiles only)
|
javax.ee.enterprise.system.nodeagent
|
|
Root
|
javax.enterprise
|
|
SAAJ
|
javax.enterprise.resource.webservices.saaj
|
|
Security
|
javax.enterprise.system.core.security
|
|
Self Management
|
javax.enterprise.system.core.selfmanagement
|
|
Server
|
javax.enterprise.system
|
|
Synchronization (cluster and enterprise profiles only)
|
javax.ee.enterprise.system.tools.synchronization
|
|
Util
|
javax.enterprise.system.util
|
|
Verifier
|
javax.enterprise.system.tools.verifier
|
|
Web Container
|
javax.enterprise.system.container.web org.apache.catalina org.apache.coyote org.apache.jasper
|
Configuring Logging
This
section contains the following topics:
Configuring General Logging Settings
To configure the general logging settings using the Admin Console:
-
For the developer profile, go to Application Server ->
Logging -> General
-
For the cluster and enterprise profiles, go to Configurations ->
Configuration -> Logging Settings -> General
On the General page, enter appropriate values to customize logging to
your requirements. Stop and restart the Application Server.
For details on setting the various configuration parameters, click Help
in the Admin Console.
To configure these log settings in asadmin, use the get and set commands.
Configuring Log Levels
To configure log levels using the Admin Console:
-
For the developer profile, go to Application Server ->
Logging -> Log Levels
-
For the cluster and enterprise profiles, go to Configurations ->
Configuration -> Logging -> Logging Settings -> Log Levels
Set the log level for the modules listed on this page. Use the Additional
Properties area to configure log levels for any application loggers. For a
list of the module loggers, see The Logger Namespace Hierarchy.
For details on setting the various configuration parameters, click Help
in the Admin Console.
To configure these log settings in asadmin, use the get and set commands.
Viewing Server Logs
To view the log files:
-
In the developer and cluster profiles, go to Applications
Server -> Logging -> View Log Files.
-
In the
enterprise profile, go to Configurations -> Configuration -> Logger Settings ->
General, and click View Log Files.
Use the options provided in the Search Criteria area to display log
results based on your preferences.
-
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):
For example:
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 Configuring 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 arrow 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
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:
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.