dev@glassfish.java.net

Re: Logging messages in GlassFish v3.1

From: Naman Mehta <Naman.Mehta_at_Sun.COM>
Date: Wed, 26 May 2010 21:51:06 +0530

Tom Mueller wrote:
> Naman,
> Thank you for this information. After reading through the referenced
> wiki page, I had a couple of questions.
>
> 1. When message ids are assigned to messages in LogStrings.properties,
> does the developer need to do anything else to notify anyone that this
> has been done. For example, do doc writers need to be informed that
> this message has to be documented? Or are new or changed messages
> automatically picked up by tools?
No need as of now. I have plan to add wiki page for the same so it
should be accessible by end user. This wiki page is coming first time so
no need of notification to doc team. I will check with doc team for the
same.
>
> 2. How does one get a new subsystem id to use for messages, while
> ensuring that it is unique?
Message id should start with character and followed by integer number.
First characters should be module name so it should be always unique for
different modules. In below example for EJB module message id starts
with 'EJB' followd by number. Within module developer needs to take care
for the same by looking at their LogStrings.properties file.

Regards,
Naman
>
> Thanks
> Tom
>
>
> On 5/26/2010 2:05 AM, Naman Mehta wrote:
>> Hi all,
>>
>> We are getting started with the 3.1 code and I wanted to send out a
>> note about logging messages in GlassFish v3.1.
>>
>> I wanted to make sure we all use the GlassFish logging mechanism as
>> it was intended. We have not changed the usage of logging in 3.1 from
>> 3.0.
>>
>> *
>> Specific Requirements for 3.1:*
>> 1. ALL messages of level SEVERE, WARNING and INFO must have a message
>> id. Log messages level SEVERE, WARNING and INFO should be in
>> LogStrings.properties file. All messages in the LogStrings.properties
>> file must have a message id. Please see the wiki page for information
>> on message ids:
>> http://wiki.glassfish.java.net/Wiki.jsp?page=GlassFishV3LoggingMessageFormat
>> .
>>
>> 2. All SEVERE and WARNING messages must have diagnostic info too.
>> Below is an example I got from the EJB module. It shows the code and
>> the entries in the the LogStrings.properties file.
>>
>>
>> *Example code from EJB module: *
>> 1. Java File entry:
>> Logger _logger = LogDomains.getLogger(EJBSecurityManager.class,
>> LogDomains.EJB_LOGGER);
>> _logger.log(Level.SEVERE, "jacc_policy_context_exception", cause);
>>
>> 2. LogStrings.properties file entry:
>> jacc_policy_context_exception=EJB5183:JACC: Unexpected exception
>> manipulating policy context
>> EJB5183.diag.cause.1=An Exception was thrown while resetting the
>> policycontext
>> EJB5183.diag.check.1=Check the EJB policy to see if the policy
>> contexts of the application are correct
>>
>> *
>> Right now I am creating defects for following:*
>> 1. Missing message Ids in LogStrings.properties file.
>> 2. Unused message Keys from LogStrings.properties file.
>> 3. Hard-coded messages in Java file for Logging.
>>
>> I have the script for verifying logging messages. Planning to
>> integrate the same in quicklook. Let you know on this.
>>
>> If you have any question please let me know.
>>
>> Regards,
>> Naman
>
> --
> Oracle <http://www.oracle.com>
> Tom Mueller | Principal Member of Technical Staff
> Phone: +1 4029169943 | Fax: +1 4029169943 | Mobile: +1 4027206872
> 21915 Hillandale Dr | Elkhorn, NE 68022
> Green Oracle <http://www.oracle.com/commitment> Oracle is committed to
> developing practices and products that help protect the environment