1. Overview of GlassFish Server Administration
Default Settings and Locations
Instructions for Administering GlassFish Server
4. Administering the Virtual Machine for the Java Platform
6. Administering Web Applications
7. Administering the Logging Service
Configuring the Logging Service
Changing the Name and Location of Logging Service Files
To Change the Name and Location of the Log File
To Change the Name and Location of the Logging Properties File
To Change the Rotation File Size
To Change the File Rotation Interval
To Change the Limit Number of Retained Files
To Collect Log Files into a ZIP Archive
8. Administering the Monitoring Service
9. Writing and Running JavaScript Clients to Monitor GlassFish Server
10. Administering Life Cycle Modules
11. Extending and Updating GlassFish Server
Part II Resources and Services Administration
12. Administering Database Connectivity
13. Administering EIS Connectivity
14. Administering Internet Connectivity
15. Administering the Object Request Broker (ORB)
16. Administering the JavaMail Service
17. Administering the Java Message Service (JMS)
18. Administering the Java Naming and Directory Interface (JNDI) Service
19. Administering Transactions
This section contains the following topics:
This section explains how to change the name and location of the following logging service files:
Log file
Logging properties file
To change the name and location of the log file, first use the list-log-attributes subcommand to obtain the current log attribute setting for the log file name and location. Then use the set-log-attributes subcommand to specify the new name or location. The default target for these two subcommands is the DAS. However, you can optionally specify one of the following targets:
Configuration name — to target all instances or clusters that share a specific configuration name.
Server name — to target only a specific server.
Instance name — to target only a specific instance.
Cluster name — to target only a specific cluster.
Remote subcommands require a running server.
The name and location of the log file is set with the com.sun.enterprise.server.logging.GFFileHandler.file attribute of the logging properties file. Optionally you can target a configuration, server, instance, or cluster. If you do not specify a target, the log attribute settings for the DAS are displayed.
If you do not specify a target, the log file for the DAS is targeted by default. If you target a cluster, the name of the cluster log file for each member instance can be changed (the server log file name cannot).
Example 7-1 Changing the Name and Location of a Cluster's Log File
This example changes the name of the cluster log file for Cluster1 to cluster1.log. Cluster1 has two server instances: ClusterServer1 and ClusterServer2.
asadmin> list-log-attributes Cluster1 com.sun.enterprise.server.logging.GFFileHandler.alarms <false> com.sun.enterprise.server.logging.GFFileHandler.file <${com.sun.aas.instanceRoot}/logs/server.log> com.sun.enterprise.server.logging.GFFileHandler.flushFrequency <1> . . . log4j.logger.org.hibernate.validator.util.Version <warn> Command list-log-attributes executed successfully. asadmin> set-log-attributes --target Cluster1 com.sun.enterprise.server.logging.GFFileHandler.file= ${com.sun.aas.instanceRoot}/logs/cluster1.log com.sun.enterprise.server.logging.GFFileHandler.file logging attribute set with value ${com.sun.aas.instanceRoot}/logs/cluster1.log These logging attributes are set for Cluster1. ClusterServer1 : com.sun.enterprise.server.logging.GFFileHandler.file logging attribute set with value ${com.sun.aas.instanceRoot}/logs/cluster1.log These logging attributes are set for Cluster1. ClusterServer2 : com.sun.enterprise.server.logging.GFFileHandler.file logging attribute set with value ${com.sun.aas.instanceRoot}/logs/cluster1.log These logging attributes are set for Cluster1. Command set-log-attributes executed successfully.
See Also
You can view the full syntax and options of these subcommands by typing asadmin help list-log-levels and asadmin help set-log-attributes at the command line.
You can set the name and location of the logging properties file by setting the java.util.logging.config.file system property. By setting this system property, you can have a single logging properties file that is used by all instances running on the same host.
Note - Setting the java.util.logging.config.file system property causes all other Oracle GlassFish Server logging properties files on the host to be overridden.
For example, you can use the following java command:
java -Djava.util.logging.config.file=properties_file
Alternatively, you can use the Administration Console to set this system property.
Example 7-2 Setting the java.util.logging.config.file System Property
The following example changes the location of the logging properties file to /space/mylogging/logging.properties:
java -Djava.util.logging.config.file=/space/mylogging/logging.properties
The log level determines the granularity of the message that is logged, from error only (SEVERE) to detailed debug (FINEST). The following values apply: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST. These log levels are hierarchically inclusive, which means that if you set a particular log level, such as INFO, the messages that have log levels above that level (SEVERE and WARNING) are also included. If you set the log level to the lowest level, FINEST, your output includes all the messages in the file. The default setting is INFO.
You can list current log levels of all loggers specified in the logging properties file. In some cases, loggers that have not been created by the respective containers will also appear in the list.
You can set log levels that are global or logger-specific. When you set a global log level, the log level goes into effect for all loggers. If you set the log level for a specific logger that is different from the global log level, the logger-specific setting takes precedence. In addition, when setting log levels, you can target a configuration, server, instance, or cluster.
Because setting log levels is a dynamic operation, you do not need to restart Oracle GlassFish Server for changes to take effect.
Setting either global or logger-specific log levels is done by using the set-log-levels subcommand. Listing log levels is done by using the list-log-levels subcommand.
The following topics are addressed here:
Oracle GlassFish Server provides the means to list all loggers and their log levels. Listing the loggers provides a convenient means to view current loggers and log levels either prior to or after making log level changes.
Use the list-log-levels subcommand in remote mode to list the modules and their current log levels. The default target for this subcommand is the DAS. However, you can optionally specify one of the following targets:
Configuration name — to target all instances or clusters that share a specific configuration name.
Server name — to target a specific server.
Instance name — to target a specific instance.
Cluster name — to target a specific cluster.
Remote subcommands require a running server.
Example 7-3 Listing Logger Levels for Modules
This example shows a partial list of the existing loggers and their log levels in the DAS.
asadmin> list-log-levels javax.enterprise.system.container.cmp <INFO> javax.enterprise.system.tools.admin <INFO> java.util.logging.ConsoleHandler <FINEST> javax.enterprise.system.container.web <INFO> javax.enterprise.system.util <INFO> javax.enterprise.resource.webcontainer.jsf.timing <INFO> javax <INFO> javax.enterprise.resource.corba <INFO> ... Command list-log-levels executed successfully.
Example 7-4 Listing Log Levels for an Instance
This example shows a partial list of the loggers and log levels for the instance MyServer2.
asadmin> list-log-levels MyServer2 java.util.logging.ConsoleHandler <FINEST> javax.enterprise.resource.corba <INFO> javax.enterprise.resource.javamail <INFO> javax.enterprise.resource.jdo <INFO> javax.enterprise.resource.jms <INFO> javax.enterprise.resource.jta <INFO> javax.enterprise.resource.resourceadapter <INFO> javax.enterprise.resource.sqltrace <FINE> ... Command list-log-levels executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help list-log-levels at the command line.
The global log level specifies the events that are logged across all loggers. The default level for messages output to the console is INFO (which also includes SEVERE and WARNING messages).
Use the set-log-levels subcommand in remote mode to set the global log level. The default target for this subcommand is the DAS. However, you can optionally specify one of the following targets using the --target option:
Configuration name — to target all instances or clusters that share a specific configuration name.
Server name — to target a specific server.
Instance name — to target a specific instance.
Cluster name — to target a specific cluster.
The ConsoleHandler has a separate log level setting that limits the messages that are displayed. For example:
java.util.logging.ConsoleHandler <FINEST>
Example 7-5 Changing the Global Log Level for All Module Loggers
By setting the log level of the ConsoleHandler, you set the global log level for all loggers. This example sets the global log level in the DAS to INFO:
asadmin> set-log-levels java.util.logging.ConsoleHandler=INFO java.util.logging.ConsoleHandler package set with log level INFO. These logging levels are set for server. Command set-log-levels executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-levels at the command line.
A module log level specifies the events that are logged for a particular logger. The default level for messages output to the console is INFO (which also includes SEVERE and WARNING messages). The global log level is overridden by a module-specific log level.
By default, the module log level is set to FINE. The lines for the loggers in the logging properties file might look like this (the modules are indicated in bold):
javax.enterprise.system.tools.level=FINE javax.enterprise.system.container.ejb.level=FINE javax.enterprise.system.core.security.level=FINE javax.enterprise.system.tools.admin.level=FINE javax.enterprise.level=FINE javax.enterprise.system.container.web.level=FINE
Because setting log levels is a dynamic operation, you do not need to restart Oracle GlassFish Server for changes to take effect.
Remote subcommands require a running server.
Your choices are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST.
Example 7-6 Setting the Log Level for a Module Logger
This example sets the log level for the web container logger to WARNING on the target instance ManagedServer1:
asadmin> set-log-levels --target ManagedServer1 javax.enterprise.system.container.web=WARNING javax.enterprise.system.container.web package set with log level WARNING. These logging levels are set for ManagedServer1. ManagedServer1 : javax.enterprise.system.container.web package set with log level WARNING. These logging levels are set for ManagedServer1. Command set-log-levels executed successfully.
Example 7-7 Setting Log Levels for Multiple Loggers
The following example sets the log level for security and web container loggers in the DAS.
asadmin> set-log-levels javax.enterprise.system.core.security=FINE: javax.enterprise.system.container.web=WARNING javax.enterprise.system.container.web package set with log level WARNING. javax.enterprise.system.core.security package set with log level FINE. These logging levels are set for server. Command set-log-levels executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-levels at the command line.
As explained in Log Files, Oracle GlassFish Server by default rotates log files when they reach 2 MB in size. However, you can change the default rotation settings. For example, you can change the file size at which the server rotates the log file or you can configure a server to rotate log files based on a time interval. In addition to changing when rotation occurs, you can also:
Specify the maximum number of rotated files that can accumulate.
By default, Oracle GlassFish Server does not limit the number of rotated log files that are retained. However, you can set a limit. After the number of log files reaches this limit, subsequent file rotations delete the oldest rotated log file.
Rotate the log file manually.
A manual rotation forces the immediate rotation of the target log file.
Changing the default log rotation settings is done using the set-log-attributes subcommand, and rotating log files manually is done using the rotate-log subcommand, as explained in the following sections:
Use the set-log-attributes subcommand in remote mode to change the log rotation file size. The default target of this subcommand is the DAS. Optionally, you can target a configuration, server, instance, or cluster. The minimum size that can be set is 500 KB.
com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=bytes
Example 7-8 Changing the Rotation Size
The following example sets the log file rotation size to 1 MB for the standalone instance ManagedServer1:
asadmin> set-log-attributes --target ManagedServer1 com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes=1000000 com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes logging attribute set with value 1000000. These logging attributes are set for ManagedServer1. ManagedServer1 : com.sun.enterprise.server.logging.GFFileHandler.rotationLimitInBytes logging attribute set with value 1000000. These logging attributes are set for ManagedServer1. Command set-log-attributes executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-attributes at the command line.
Use the set-log-attributes subcommand in remote mode to change the log file rotation time limit interval. The default target of this subcommand is the DAS. Optionally, you can target a configuration, server, instance, or cluster. The default value is 0.
com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=minutes
Example 7-9 Changing the Rotation Interval
The following example sets the log file rotation time limit for the cluster Cluster1, which has the instances ClusterServer1 and ClusterServer2.
asadmin> set-log-attributes --target Cluster1 com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes=10 com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes logging attribute set with value 10. These logging attributes are set for Cluster1. ClusterServer1 : com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes logging attribute set with value 10. These logging attributes are set for Cluster1. ClusterServer2 : com.sun.enterprise.server.logging.GFFileHandler.rotationTimelimitInMinutes logging attribute set with value 10. These logging attributes are set for Cluster1. Command set-log-attributes executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-attributes at the command line.
Use the set-log-attributes subcommand in remote mode to change the limit on the number of log files that the server creates to store old log messages. The default target of this subcommand is the DAS. Optionally, you can target a configuration, server, instance, or cluster. The default limit value is 0, which results in no limit placed on the number of rotated log files that are retained.
com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles=minutes
The behavior of the com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles attribute is as follows:
If the property is not set, Oracle GlassFish Server keeps a maximum of 10 rotated log files.
If the property is set to an invalid number or null, Oracle GlassFish Server keeps a maximum of 10 rotated log files.
If the property is set to 0, Oracle GlassFish Server retains all rotated log files (that is, no sets no maximum).
Example 7-10 Changing the Limit Number of Retained Files
The following example sets the log limit number of retained log files for the DAS to 10.
asadmin> set-log-attributes com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles=10 com.sun.enterprise.server.logging.GFFileHandler.maxHistoryFiles logging attribute set with value 10. These logging attributes are set for server. Command set-log-attributes executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-attributes at the command line.
You can rotate log files manually by using the rotate-log subcommand in remote mode. The default target of this subcommand is the DAS. Optionally, you can target a configuration, server, instance, or cluster. When you use this subcommand, the target log file is immediately moved to a new time-stamped file and a new log file is created.
Because log rotation is a dynamic operation, you do not need to restart Oracle GlassFish Server for changes to take effect.
Example 7-11 Rotating Log Files Manually
The following example rotates the server.log file for ManagedServer2 to server.log_yyyy-mm-ddThh-mm-ss, where yyyy-mm-ddThh-mm-ss represents the time when the file is rotated, and creates a new server.log file in the default location.
asadmin> rotate-log --target ManagedServer2 Command rotate-log executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help rotate-log at the command line.
By default, Oracle GlassFish Server log records are captured in a server log file using the format described in Log Records. However, you may find that you want to log messages to a different location, such as a database or a remote server, or log messages from specific loggers to your own file. This can be done by implementing a custom log handler. This section explains how to add a custom log handler to the Oracle GlassFish Server logging service.
A comma-separated list of log handlers is installed during startup of the Java Virtual Machine (JVM) host. The default log handler that is provided in the logging.properties file, ConsoleHandler, is configured as follows:
handlers=java.util.logging.ConsoleHandler
In Oracle GlassFish Server, the best approach to developing a custom handler is to define a Hundred-Kilobyte Kernel (HK2) component that implements the handler contract. Oracle GlassFish Server registers this handler automatically because it is an HK2 component. There is no task required of the administrator.
To configure a custom handler that is not developed as an HK2 component, add the new handler to the logging.properties file after the developer has put the custom handler JAR file into the domain-dir/lib/ext directory.
Before You Begin
If you set a handler by setting the handlers attribute in the logging properties file, the class that extends java.util.logging.Handler must be in the server classpath.
Remote subcommands require a running server.
The default target of this subcommand is the DAS. Optionally you can target a configuration, server, instance, or cluster.
See To Restart a Domain.
Example 7-12 Adding a New Log Handler
This example adds the custom logger com.example.logging.MyHandler to the logging properties file of the DAS.
asadmin> set-log-attributes handlers=java.util.logging.ConsoleHandler,com.example.logging.MyHandler handlers logging attribute set with value java.util.logging.ConsoleHandler,com.example.logging.MyHandler. These logging attributes are set for server. Command set-log-attributes executed successfully.
See Also
You can view the full syntax and options of the subcommand by typing asadmin help set-log-attributes at the command line.