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
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 FormatEach message that is written to the logs or the console will be formatted as described below. [#|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 RequirementFor 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} 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. 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>); |