dev@glassfish.java.net

Re: logger printing message param twice

From: Byron Nevins <Byron.Nevins_at_Sun.COM>
Date: Fri, 23 Feb 2007 12:57:48 -0800

My mistake - I was thinking of local strings for some reason. The code
below may help Bobby dignose...

String s = logger.getResourceBundle().getString('some_key");
            MessageFormat mf = new MessageFormat(s);
            string finalString = mf.format(objects);


kedar wrote:
> I am sorry, but Byron, this is not the
> right use of logging for log records, because
> the log records need to have an ID, something like:
> ADM1014: MBeanServer initialized ...
> etc.
>
> If you use ubiquitous LocalString.properties to
> get the log records from, then you lose this information.
> That's why we have localized log-records placed at
> one single place according to logger structure, and we
> need to use a reference to those, especially when
> we are logging records with "INFO", "WARNING", "SEVERE".
>
> The file to use is LogStrings.properties and not LocalStrings.properties.
> The former is for log records, the latter for exception
> messages.
>
> You'll find LogStrings.properties in appserv-commons arranged
> according to your module logger.
>
> I understand that this is a bit clumsy, but error messages and
> diagnosis guide is based on this.
>
> What Robert is facing might be an issue that needs to be
> analyzed.
>
> Kedar
>
> Byron Nevins wrote:
>> I've never heard of this behavior -- and I write lots of similar
>> messages. If the String is in LocalStrings.properties in the class'
>> package -- then I would do this:
>>
>> import com.sun.enterprise.util.LocalStringsImpl;
>>
>> yourCode()
>> {
>> LocalStringsImpl stringy = new LocalStringsImpl();
>> String s = stringy.get("some_key", someObject);
>> logger.log(SEVERE, s);
>> }
>> Now you at least have a chance of figuring it out via a debugger...
>>
>>
>> Bobby Bissett - Javasoft wrote:
>>> I have code that is logging a Level.SEVERE message as so:
>>>
>>> logger.log(Level.SEVERE, "some_key", someObject);
>>>
>>> With log string:
>>>
>>> some_key=My message {0}
>>>
>>> In the log output, I'm seeing the someObject.toString() text twice,
>>> once before "My message" and once again after. Is this by design? It
>>> creates too much output this way (the object is an expired cert and
>>> it prints ~25 lines).
>>>
>>> I see in UniformLogFormatter.uniformLogFormat() it calls
>>> getNameValuePairs() before appending the message and object, and
>>> getNameValuePairs() appends someObject.toString() before returning
>>> so that the same information is in the log message twice.
>>>
>>> Can someone tell me if this is a bug? If not, is there a different
>>> way to call the logger so I don't generate this much output? I would
>>> like to give as much information as possible in this message (it's
>>> SEVERE), but I don't want to give it twice.
>>>
>>> Thanks,
>>> Bobby
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>