This page addresses the specifics for the GlassFish message format and message id requirements. Implementation details are described in the one pager though some information it provided here because it is useful for developers that use the logging mechanism.

Logging requirements addressed on this page

  1. Log messages shall have a common/uniform format.
  2. Every SEVERE, WARNING and INFO Log message shall have a unique key (such as unique message id) that can be used to index into a operational manual or on-line database.

Message Files in GlassFish

Messages that the GlassFish server logs can be found in usually one of two files in the workspace. Most messages that are logged to the server log file are found in files called LogStrings.properties. These messages follow the format described here. All messages in these files require a message id and all SEVERE and WARNING level messages require diagnostic information. All messages in these files are localized.

In addition, there are files called LocalStrings.properties which contain messages that are for GlassFish CLI or exception messages. These messages do not require a message id nor do they required diagnostic information. Some components that were brought into GlassFish such as Tomcat code use files called LocalStrings.properties for messages that are logged. By default any messages from these files have a INFO level if they are logged to the server log file. All messages in LocalStrings.properties are also localized.

Uniform Logging Format

Each message that is written to the logs or the console will be formatted as described below.
There are 6 fields in a record each separated by a '|'. Within a field there may be additional delimiter. Name Value Pairs use a semi-colon between pairs and the Message Id is the first string in the message text that ends with a colon.
Each record contains a beginning and ending marker. Begin marker is # and end marker is #
Date Time is Internet Standard format
Level is the level of this message (SEVERE, WARNING, INFO, FINE, FINER or FINEST)
ProductId is "glassfishv3.0", etc.
Logger name is found in logging.properties file
Name Value pairs - formatter adds information about the thread id and thread name. Each pair is separated by a ';'
Message begins with the MsgId delimited by a ':' followed by the text of the message
Generic record format:

[#|yyyy-mm-ddTHH:mm:ss:SSS-ZZZZ|Level|ProductId|Logger Name|Name Value Pairs|MsgId: Message|#]

Sample record format:

[#|2009-08-06T13:41:09.192-0700|INFO|glassfish|javax.enterprise.system.core.security.com.sun.enterprise.security|_ThreadID=20;_ThreadName=Thread-1;|SEC1002: Security Manager is OFF.|#]

Message Id Requirement

For v3 the requirement applies to SEVERE and WARNING messages only. In later versions of v3 message ids are required for INFO level messages too.

SEVERE, WARNING and INFO level messages are actually in a resource bundle and not in the Java files. Generally the resource bundle's name is LogStrings.properties. See java.text.MessageFormat for details on constructing messages. Messages in this file must be of the form

<Subsystem><4CharIntegerMessageId>: <message text>

example.message1=CMNUTL0001: Test Message. Parameter 1={0} parameter 2={1}
In this example, 'CMNUTL0001: Test Message. Parameter 1={0} parameter 2={1}' becomes the message body (MsgId: Message) field of the format described above. 'CMNUTL001:' is the message id and is used to find diagnostic information if it is present.

Diagnostic Information:

In addition, diagnostic information should also appear in the Resource Bundle. Diagnostic information begins with a message id pre-appended to the string 'cause' or 'check'. See below for complete details on the message format. At least one 'cause' and at least one 'check' message is required for all messages level SEVERE and WARNING. Each message id is made up a set of characters and integers. There will be upto 6 characters to identify the module and upto 4 digits to identify the message within the module.

<6CharIntegerMessageId>.diag.cause.int=<message text>
<6CharIntegerMessageId>.diag.check.int=<message text>

There may be more than one 'cause' or 'check' message for each message id. Multiple diagnostic information for a message is indicated by a number starting with 1.
An example entry in the resource bundle would be:

enterprise.deployment.backend.fileCopyFailure=DPL8002: file copy failure
DPL8002.diag.cause.1=Copying of files failed
DPL8002.diag.cause.2=May be because of lack of space or permission
DPL8002.diag.check.1=Ensure that there is enough disk space
DPL8002.diag.check.2=Ensure that the permissions are set as expected

Below are code examples for logging messages in GlassFish:

_logger.warning(<message key>);
_logger.log(Level.WARNING, <message key>);