This section explains how to configure logging for Enterprise Server by setting properties in the logging.properties file. Log level configuration changes are dynamic and do not require that you restart the server, but other configuration changes do require you to restart the server.
The following topics are addressed here:
The following tasks apply to configuring log handler elements:
You can modify logging behavior by setting properties in the logging.properties file as follows:
In a text editor, find the property that you want to modify and make your changes.
The following properties are available:
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
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
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
Uses UniformLogFormatter to format the records in the log file.
com.sun.enterprise.server.logging.FileandSyslogHandler.formatter=com. sun.enterprise.server.logging.UniformLogFormatter
Save the file.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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 |
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.
In a text editor, add the new file handler to the line that begins with handlers=.
Save the file.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
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 |
The log level describes the type of material that is contained in the message. 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 will include all the messages in the file. The default setting is INFO.
There are two levels of log settings available: global and logger-specific. If you have chosen a logger-specific setting that is different from the global setting, the logger-specific setting takes precedence.
Because setting log levels is a dynamic operation, you do not need to restart Enterprise Server for changes to take effect.
The following topics are addressed here:
The global log level specifies which kinds of events are logged across all loggers. The default level for message output to the console is INFO (which also includes SEVERE and WARNING messages).
The ConsoleHandler has a separate log level setting that limits the messages that are displayed. For example:
java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.formatter = com.sun.enterprise.server.logging.UniformLogFormatter |
If you set the log level at the root level, you are setting the level of all loggers. The following example sets the log level for all loggers to INFO:
.level= INFO
Logger-specific properties provide extra control for the logger of each module. By default, these properties are set to log level FINE in the logging. properties file, however, the lines in the file are commented out. The lines for the loggers 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 |
For any given module logger, such as the EJB logger, the global log level can be overridden by the module-specific setting.
In a text editor, uncomment the line that applies to the logger that you want to modify.
Remove the #. The logger is activated using the default level INFO.
Set the property to the desired log level.
Your choices are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, and FINEST.
Save the file.
The log levels are automatically updated.
The following example changes the log level for ConsoleHandler from INFO to FINE
Before:
java.util.logging.ConsoleHandler.level = INFO |
After:
java.util.logging.ConsoleHandler.level = FINE |
The following example sets the log level for the EJB logger to SEVERE (overriding the global level INFO)
Before:
#javax.enterprise.system.container.ejb.level=FINE
After: :
javax.enterprise.system.container.ejb.level=SEVERE
By default, the name of the log output file is server.log and it is located in domain-dir/logs. You can change the name or location of the file by editing the logging.properties file as follows:
In a text editor, find the following line:
com.sun.enterprise.server.logging.FileandSyslogHandler.file=logs/server.log
In this line, logs indicates the directory where the file is located, and server.log is the file name.
Make your changes and save the file.
To apply your changes, restart Enterprise Server.
Stop Enterprise Server.
For instructions, see To Stop a Domain (or Server).
Start Enterprise Server.
For instructions, see To Start a Domain (or Server).
The following example changes the log file name from server.log to myLogging.log and changes the location from the logs directory to the dpin directory:
Before:
com.sun.enterprise.server.logging.FileandSyslogHandler.file=logs/server.log
After:
com.sun.enterprise.server.logging.FileandSyslogHandler.file=dpin/myLogging.log